OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SERVICE_SERVICE_PROCESS_CONTROL_H_ | 5 #ifndef CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_ |
6 #define CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_ | 6 #define CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
| 9 #include <string> |
9 | 10 |
10 #include "base/id_map.h" | 11 #include "base/id_map.h" |
| 12 #include "base/callback.h" |
11 #include "base/process.h" | 13 #include "base/process.h" |
12 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
13 #include "base/task.h" | 15 #include "base/task.h" |
14 #include "chrome/common/service_process_type.h" | 16 #include "chrome/common/service_process_type.h" |
15 #include "ipc/ipc_sync_channel.h" | 17 #include "ipc/ipc_sync_channel.h" |
16 | 18 |
17 class Profile; | 19 class Profile; |
18 | 20 |
19 // A ServiceProcessControl works as a portal between the service process and | 21 // A ServiceProcessControl works as a portal between the service process and |
20 // the browser process. | 22 // the browser process. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 void Launch(Task* launch_done_task); | 64 void Launch(Task* launch_done_task); |
63 | 65 |
64 // IPC::Channel::Listener implementation. | 66 // IPC::Channel::Listener implementation. |
65 virtual void OnMessageReceived(const IPC::Message& message); | 67 virtual void OnMessageReceived(const IPC::Message& message); |
66 virtual void OnChannelConnected(int32 peer_pid); | 68 virtual void OnChannelConnected(int32 peer_pid); |
67 virtual void OnChannelError(); | 69 virtual void OnChannelError(); |
68 | 70 |
69 // IPC::Channel::Sender implementation | 71 // IPC::Channel::Sender implementation |
70 virtual bool Send(IPC::Message* message); | 72 virtual bool Send(IPC::Message* message); |
71 | 73 |
| 74 // Message handlers |
| 75 void OnGoodDay(); |
| 76 void OnCloudPrintProxyIsEnabled(bool enabled, std::string email); |
| 77 |
72 // Send a hello message to the service process for testing purpose. | 78 // Send a hello message to the service process for testing purpose. |
73 // Return true if the message was sent. | 79 // Return true if the message was sent. |
74 bool SendHello(); | 80 bool SendHello(); |
75 | 81 |
76 // Send a shutdown message to the service process. IPC channel will be | 82 // Send a shutdown message to the service process. IPC channel will be |
77 // destroyed after calling this method. | 83 // destroyed after calling this method. |
78 // Return true if the message was sent. | 84 // Return true if the message was sent. |
79 bool Shutdown(); | 85 bool Shutdown(); |
80 | 86 |
81 // Send a message to enable the remoting service in the service process. | 87 // Send a message to enable the remoting service in the service process. |
82 // Return true if the message was sent. | 88 // Return true if the message was sent. |
83 bool EnableRemotingWithTokens(const std::string& user, | 89 bool EnableRemotingWithTokens(const std::string& user, |
84 const std::string& remoting_token, | 90 const std::string& remoting_token, |
85 const std::string& talk_token); | 91 const std::string& talk_token); |
86 | 92 |
| 93 // Send a message to the service process to request a response |
| 94 // containing the enablement status of the cloud print proxy and the |
| 95 // registered email address. The callback gets the information when |
| 96 // received. |
| 97 bool GetCloudPrintProxyStatus( |
| 98 Callback2<bool, std::string>::Type* cloud_print_status_callback); |
| 99 |
87 // Set the message handler for receiving messages from the service process. | 100 // Set the message handler for receiving messages from the service process. |
88 // TODO(hclam): Allow more than 1 handler. | 101 // TODO(hclam): Allow more than 1 handler. |
89 void SetMessageHandler(MessageHandler* message_handler) { | 102 void SetMessageHandler(MessageHandler* message_handler) { |
90 message_handler_ = message_handler; | 103 message_handler_ = message_handler; |
91 } | 104 } |
92 | 105 |
93 private: | 106 private: |
94 class Launcher; | 107 class Launcher; |
95 | 108 |
96 // Method called by Launcher when the service process is launched. | 109 // Method called by Launcher when the service process is launched. |
97 void OnProcessLaunched(Task* launch_done_task); | 110 void OnProcessLaunched(Task* launch_done_task); |
98 | 111 |
99 // Used internally to connect to the service process. |task| is executed | 112 // Used internally to connect to the service process. |task| is executed |
100 // when the connection is made or an error occurred. | 113 // when the connection is made or an error occurred. |
101 void ConnectInternal(Task* task); | 114 void ConnectInternal(Task* task); |
102 | 115 |
103 Profile* profile_; | 116 Profile* profile_; |
104 ServiceProcessType type_; | 117 ServiceProcessType type_; |
105 | 118 |
106 // IPC channel to the service process. | 119 // IPC channel to the service process. |
107 scoped_ptr<IPC::SyncChannel> channel_; | 120 scoped_ptr<IPC::SyncChannel> channel_; |
108 | 121 |
109 // Service process launcher. | 122 // Service process launcher. |
110 scoped_refptr<Launcher> launcher_; | 123 scoped_refptr<Launcher> launcher_; |
111 | 124 |
112 // Callback that gets invoked when the channel is connected or failed to | 125 // Callback that gets invoked when the channel is connected or failed to |
113 // connect. | 126 // connect. |
114 scoped_ptr<Task> connect_done_task_; | 127 scoped_ptr<Task> connect_done_task_; |
115 | 128 |
| 129 // Callback that gets invoked when a status message is received from |
| 130 // the cloud print proxy. |
| 131 scoped_ptr<Callback2<bool, std::string>::Type> cloud_print_status_callback_; |
| 132 |
116 // Handler for messages from service process. | 133 // Handler for messages from service process. |
117 MessageHandler* message_handler_; | 134 MessageHandler* message_handler_; |
118 }; | 135 }; |
119 | 136 |
120 #endif // CHROME_BROWSER_SERVICE_SERVICE_PROCESS_H_ | 137 #endif // CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_ |
OLD | NEW |