OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BROWSER_MULTI_PROCESS_NOTIFICATION_H_ | 5 #ifndef CHROME_BROWSER_MULTI_PROCESS_NOTIFICATION_H_ |
6 #define CHROME_BROWSER_MULTI_PROCESS_NOTIFICATION_H_ | 6 #define CHROME_BROWSER_MULTI_PROCESS_NOTIFICATION_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/message_loop.h" |
13 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
14 #include "base/task.h" | 15 #include "base/task.h" |
15 | 16 |
16 class Task; | 17 class Task; |
17 class MessageLoop; | 18 class MessageLoop; |
18 | 19 |
19 // Platform abstraction for a notification that can be sent between processes. | 20 // Platform abstraction for a notification that can be sent between processes. |
20 // Notifications are strings. The string will be prefixed accordingly per | 21 // Notifications are strings. The string will be prefixed accordingly per |
21 // platform (so on Mac OS X a "Happy" notification will become | 22 // platform (so on Mac OS X a "Happy" notification will become |
22 // "org.chromium.Happy"). | 23 // "org.chromium.Happy"). |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 Delegate* delegate_; | 89 Delegate* delegate_; |
89 DISALLOW_COPY_AND_ASSIGN(NotificationReceivedTask); | 90 DISALLOW_COPY_AND_ASSIGN(NotificationReceivedTask); |
90 }; | 91 }; |
91 | 92 |
92 Listener(const std::string& name, Domain domain, Delegate* delegate); | 93 Listener(const std::string& name, Domain domain, Delegate* delegate); |
93 | 94 |
94 // A destructor is required for scoped_ptr to compile. | 95 // A destructor is required for scoped_ptr to compile. |
95 ~Listener(); | 96 ~Listener(); |
96 | 97 |
97 // A listener is not considered valid until Start() returns true and its | 98 // A listener is not considered valid until Start() returns true and its |
98 // delegate's OnListenerStarted method is called with |success| == true | 99 // delegate's OnListenerStarted method is called with |success| == true. |
99 bool Start(); | 100 // |io_loop_to_listen_on| is the message loop to register the listener on. |
| 101 // All callbacks will be made in the same thread that "Start" is called on, |
| 102 // not the thread that owns io_loop_to_listen_on. |
| 103 // |io_loop_to_listen_on| must be of type TYPE_IO. |
| 104 bool Start(MessageLoop* io_loop_to_listen_on); |
| 105 |
| 106 std::string name() const; |
| 107 Domain domain() const; |
100 | 108 |
101 private: | 109 private: |
102 scoped_ptr<ListenerImpl> impl_; | 110 scoped_ptr<ListenerImpl> impl_; |
103 | 111 |
104 DISALLOW_COPY_AND_ASSIGN(Listener); | 112 DISALLOW_COPY_AND_ASSIGN(Listener); |
105 }; | 113 }; |
106 | 114 |
107 } // namespace multi_process_notification | 115 } // namespace multi_process_notification |
108 | 116 |
109 #endif // CHROME_BROWSER_MULTI_PROCESS_NOTIFICATION_H_ | 117 #endif // CHROME_BROWSER_MULTI_PROCESS_NOTIFICATION_H_ |
OLD | NEW |