OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_COMMON_CHILD_THREAD_H_ | 5 #ifndef CHROME_COMMON_CHILD_THREAD_H_ |
6 #define CHROME_COMMON_CHILD_THREAD_H_ | 6 #define CHROME_COMMON_CHILD_THREAD_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/thread.h" | 10 #include "base/thread.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // See documentation on MessageRouter for AddRoute and RemoveRoute | 27 // See documentation on MessageRouter for AddRoute and RemoveRoute |
28 void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); | 28 void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); |
29 void RemoveRoute(int32 routing_id); | 29 void RemoveRoute(int32 routing_id); |
30 | 30 |
31 MessageLoop* owner_loop() { return owner_loop_; } | 31 MessageLoop* owner_loop() { return owner_loop_; } |
32 | 32 |
33 ResourceDispatcher* resource_dispatcher() { | 33 ResourceDispatcher* resource_dispatcher() { |
34 return resource_dispatcher_.get(); | 34 return resource_dispatcher_.get(); |
35 } | 35 } |
36 | 36 |
| 37 // Returns the one child thread. |
| 38 static ChildThread* current(); |
| 39 |
37 protected: | 40 protected: |
38 friend class ChildProcess; | 41 friend class ChildProcess; |
39 | 42 |
40 // Starts the thread. | 43 // Starts the thread. |
41 bool Run(); | 44 bool Run(); |
42 | 45 |
43 // Overrides the channel name. Used for --single-process mode. | 46 // Overrides the channel name. Used for --single-process mode. |
44 void SetChannelName(const std::string& name) { channel_name_ = name; } | 47 void SetChannelName(const std::string& name) { channel_name_ = name; } |
45 | 48 |
46 // Called when the process refcount is 0. | 49 // Called when the process refcount is 0. |
47 void OnProcessFinalRelease(); | 50 void OnProcessFinalRelease(); |
48 | 51 |
49 protected: | 52 protected: |
50 // The required stack size if V8 runs on a thread. | 53 // The required stack size if V8 runs on a thread. |
51 static const size_t kV8StackSize; | 54 static const size_t kV8StackSize; |
52 | 55 |
53 virtual void OnControlMessageReceived(const IPC::Message& msg) { } | 56 virtual void OnControlMessageReceived(const IPC::Message& msg) { } |
54 | 57 |
55 // Returns the one child thread. | |
56 static ChildThread* current(); | |
57 | |
58 IPC::SyncChannel* channel() { return channel_.get(); } | 58 IPC::SyncChannel* channel() { return channel_.get(); } |
59 | 59 |
60 // Thread implementation. | 60 // Thread implementation. |
61 virtual void Init(); | 61 virtual void Init(); |
62 virtual void CleanUp(); | 62 virtual void CleanUp(); |
63 | 63 |
64 private: | 64 private: |
65 // IPC::Channel::Listener implementation: | 65 // IPC::Channel::Listener implementation: |
66 virtual void OnMessageReceived(const IPC::Message& msg); | 66 virtual void OnMessageReceived(const IPC::Message& msg); |
67 virtual void OnChannelError(); | 67 virtual void OnChannelError(); |
(...skipping 16 matching lines...) Expand all Loading... |
84 | 84 |
85 // If true, checks with the browser process before shutdown. This avoids race | 85 // If true, checks with the browser process before shutdown. This avoids race |
86 // conditions if the process refcount is 0 but there's an IPC message inflight | 86 // conditions if the process refcount is 0 but there's an IPC message inflight |
87 // that would addref it. | 87 // that would addref it. |
88 bool check_with_browser_before_shutdown_; | 88 bool check_with_browser_before_shutdown_; |
89 | 89 |
90 DISALLOW_COPY_AND_ASSIGN(ChildThread); | 90 DISALLOW_COPY_AND_ASSIGN(ChildThread); |
91 }; | 91 }; |
92 | 92 |
93 #endif // CHROME_COMMON_CHILD_THREAD_H_ | 93 #endif // CHROME_COMMON_CHILD_THREAD_H_ |
OLD | NEW |