-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the Starboard message pump. (#4772)
The setup is similar to ATV/iOS where the existing platform main thread is re-used and the UI message pump just attaches to it. b/392620765 b/391414243
- Loading branch information
Showing
34 changed files
with
388 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2025 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "base/logging.h" | ||
#include "base/memory/raw_ptr.h" | ||
#include "base/memory/singleton.h" | ||
#include "base/message_loop/message_pump.h" | ||
#include "base/message_loop/message_pump_default.h" | ||
#include "base/message_loop/message_pump_for_ui.h" | ||
#include "base/synchronization/waitable_event.h" | ||
|
||
namespace { | ||
|
||
class MessagePumpForUIStub : public base::MessagePumpUIStarboard { | ||
public: | ||
|
||
MessagePumpForUIStub() : base::MessagePumpForUI(), default_pump_ (new base::MessagePumpDefault) { } | ||
~MessagePumpForUIStub() override {} | ||
|
||
// Similar to Android, in Starboad tests there isn't a native thread, | ||
// as such RunLoop::Run() should be used to run the loop instead of attaching | ||
// and delegating to the native loop. | ||
// As such, this override ignores the Attach() request. | ||
void Attach(base::MessagePump::Delegate* delegate) override {} | ||
|
||
// --- Delegate to the MessagePumpDefault Implementation --- | ||
|
||
virtual void Run(Delegate* delegate) override { | ||
default_pump_->Run(delegate); | ||
} | ||
|
||
virtual void Quit() override { | ||
default_pump_->Quit(); | ||
} | ||
|
||
virtual void ScheduleWork() override { | ||
default_pump_->ScheduleWork(); | ||
} | ||
|
||
virtual void ScheduleDelayedWork( | ||
const Delegate::NextWorkInfo& next_work_info) override { | ||
default_pump_->ScheduleDelayedWork(next_work_info); | ||
} | ||
|
||
private: | ||
std::unique_ptr<base::MessagePumpDefault> default_pump_; | ||
}; | ||
|
||
std::unique_ptr<base::MessagePump> CreateMessagePumpForUIStub() { | ||
return std::unique_ptr<base::MessagePump>(new MessagePumpForUIStub()); | ||
} | ||
|
||
} // namespace | ||
|
||
namespace base { | ||
|
||
|
||
void InitStarboardTestMessageLoop() { | ||
if (!MessagePump::IsMessagePumpForUIFactoryOveridden()) | ||
MessagePump::OverrideMessagePumpForUIFactory(&CreateMessagePumpForUIStub); | ||
} | ||
|
||
} // namespace base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2025 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef BASE_TEST_TEST_SUPPORT_STARBOARD_H_ | ||
#define BASE_TEST_TEST_SUPPORT_STARBOARD_H_ | ||
|
||
namespace base { | ||
|
||
// Init the message loop for tests on Starboard. | ||
void InitStarboardTestMessageLoop(); | ||
|
||
} // namespace base | ||
|
||
#endif // BASE_TEST_TEST_SUPPORT_STARBOARD_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.