OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SERVICE_SERVICE_IPC_SERVER_H_ | 5 #ifndef UI_VIEWER_VIEWER_IPC_SERVER_H_ |
6 #define CHROME_SERVICE_SERVICE_IPC_SERVER_H_ | 6 #define UI_VIEWER_VIEWER_IPC_SERVER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "ipc/ipc_channel_handle.h" | 11 #include "ipc/ipc_channel_handle.h" |
12 #include "ipc/ipc_listener.h" | 12 #include "ipc/ipc_listener.h" |
13 #include "ipc/ipc_sync_channel.h" | 13 #include "ipc/ipc_sync_channel.h" |
14 #include "ipc/ipc_sync_message_filter.h" | 14 #include "ipc/ipc_sync_message_filter.h" |
15 #include "ipc/ipc_sender.h" | 15 #include "ipc/ipc_sender.h" |
16 | 16 |
17 // This class handles IPC commands for the service process. | 17 // This class handles IPC commands for the Viewer process. |
18 class ServiceIPCServer : public IPC::Listener, public IPC::Sender { | 18 class ViewerIPCServer : public IPC::Listener, public IPC::Sender { |
19 public: | 19 public: |
20 explicit ServiceIPCServer(const IPC::ChannelHandle& handle); | 20 explicit ViewerIPCServer(const IPC::ChannelHandle& handle); |
21 virtual ~ServiceIPCServer(); | 21 virtual ~ViewerIPCServer(); |
22 | 22 |
23 bool Init(); | 23 bool Init(); |
24 | 24 |
25 // IPC::Sender implementation. | 25 // IPC::Sender implementation. |
26 virtual bool Send(IPC::Message* msg) OVERRIDE; | 26 virtual bool Send(IPC::Message* msg) OVERRIDE; |
27 | 27 |
28 IPC::SyncChannel* channel() { return channel_.get(); } | 28 IPC::SyncChannel* channel() { return channel_.get(); } |
29 | 29 |
30 // Safe to call on any thread, as long as it's guaranteed that the thread's | 30 // Safe to call on any thread, as long as it's guaranteed that the thread's |
31 // lifetime is less than the main thread. | 31 // lifetime is less than the main thread. |
32 IPC::SyncMessageFilter* sync_message_filter() { return sync_message_filter_; } | 32 IPC::SyncMessageFilter* sync_message_filter() { return sync_message_filter_; } |
33 | 33 |
34 bool is_client_connected() const { return client_connected_; } | |
35 | |
36 | |
37 private: | 34 private: |
38 friend class MockServiceIPCServer; | |
39 | |
40 // IPC::Listener implementation. | 35 // IPC::Listener implementation. |
41 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 36 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
42 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 37 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
43 virtual void OnChannelError() OVERRIDE; | 38 virtual void OnChannelError() OVERRIDE; |
44 | 39 |
45 // IPC message handlers. | 40 // IPC message handlers. |
46 void OnEnableCloudPrintProxy(const std::string& lsid); | 41 void OnPbufferHandle(const std::string& todo); |
47 void OnEnableCloudPrintProxyWithRobot( | |
48 const std::string& robot_auth_code, | |
49 const std::string& robot_email, | |
50 const std::string& user_email); | |
51 void OnGetCloudPrintProxyInfo(); | |
52 void OnDisableCloudPrintProxy(); | |
53 void OnEnableVirtualDriver(); | |
54 void OnDisableVirtualDriver(); | |
55 | |
56 void OnShutdown(); | |
57 void OnUpdateAvailable(); | |
58 | 42 |
59 // Helper method to create the sync channel. | 43 // Helper method to create the sync channel. |
60 void CreateChannel(); | 44 void CreateChannel(); |
61 | 45 |
| 46 bool client_connected_; |
| 47 |
62 IPC::ChannelHandle channel_handle_; | 48 IPC::ChannelHandle channel_handle_; |
63 scoped_ptr<IPC::SyncChannel> channel_; | 49 scoped_ptr<IPC::SyncChannel> channel_; |
64 // Indicates whether a client is currently connected to the channel. | |
65 bool client_connected_; | |
66 | 50 |
67 // Allows threads other than the main thread to send sync messages. | 51 // Allows threads other than the main thread to send sync messages. |
68 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; | 52 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; |
69 | 53 |
70 | 54 DISALLOW_COPY_AND_ASSIGN(ViewerIPCServer); |
71 DISALLOW_COPY_AND_ASSIGN(ServiceIPCServer); | |
72 }; | 55 }; |
73 | 56 |
74 #endif // CHROME_SERVICE_SERVICE_IPC_SERVER_H_ | 57 #endif // UI_VIEWER_VIEWER_IPC_SERVER_H_ |
OLD | NEW |