Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2976)

Unified Diff: chrome/common/child_thread.h

Issue 155876: Revert r21117 as it caused reliability failures.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/child_process.cc ('k') | chrome/common/child_thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/child_thread.h
===================================================================
--- chrome/common/child_thread.h (revision 21215)
+++ chrome/common/child_thread.h (working copy)
@@ -7,20 +7,18 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
+#include "base/thread.h"
#include "chrome/common/ipc_sync_channel.h"
#include "chrome/common/message_router.h"
#include "chrome/common/resource_dispatcher.h"
-class NotificationService;
-
-// The main thread of a child process derives from this class.
+// Child processes's background thread should derive from this class.
class ChildThread : public IPC::Channel::Listener,
- public IPC::Message::Sender {
+ public IPC::Message::Sender,
+ public base::Thread {
public:
// Creates the thread.
- ChildThread();
- // Used for single-process mode.
- ChildThread(const std::string channel_name);
+ ChildThread(Thread::Options options);
virtual ~ChildThread();
// IPC::Message::Sender implementation:
@@ -30,39 +28,58 @@
void AddRoute(int32 routing_id, IPC::Channel::Listener* listener);
void RemoveRoute(int32 routing_id);
+ MessageLoop* owner_loop() { return owner_loop_; }
+
ResourceDispatcher* resource_dispatcher() {
return resource_dispatcher_.get();
}
- MessageLoop* message_loop() { return message_loop_; }
-
// Returns the one child thread.
static ChildThread* current();
protected:
friend class ChildProcess;
+ // Starts the thread.
+ bool Run();
+
+ // Overrides the channel name. Used for --single-process mode.
+ void SetChannelName(const std::string& name) { channel_name_ = name; }
+
// Called when the process refcount is 0.
void OnProcessFinalRelease();
+ protected:
+ // The required stack size if V8 runs on a thread.
+ static const size_t kV8StackSize;
+
virtual void OnControlMessageReceived(const IPC::Message& msg) { }
IPC::SyncChannel* channel() { return channel_.get(); }
+ // Thread implementation.
+ virtual void Init();
+ virtual void CleanUp();
+
private:
- void Init();
-
// IPC::Channel::Listener implementation:
virtual void OnMessageReceived(const IPC::Message& msg);
virtual void OnChannelError();
+ // The message loop used to run tasks on the thread that started this thread.
+ MessageLoop* owner_loop_;
+
std::string channel_name_;
scoped_ptr<IPC::SyncChannel> channel_;
- // Implements message routing functionality to the consumers of ChildThread.
+ // Used only on the background render thread to implement message routing
+ // functionality to the consumers of the ChildThread.
MessageRouter router_;
+ Thread::Options options_;
+
// Handles resource loads for this process.
+ // NOTE: this object lives on the owner thread.
scoped_ptr<ResourceDispatcher> resource_dispatcher_;
// If true, checks with the browser process before shutdown. This avoids race
@@ -70,10 +87,6 @@
// that would addref it.
bool check_with_browser_before_shutdown_;
- MessageLoop* message_loop_;
-
- scoped_ptr<NotificationService> notification_service_;
-
DISALLOW_COPY_AND_ASSIGN(ChildThread);
};
« no previous file with comments | « chrome/common/child_process.cc ('k') | chrome/common/child_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698