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 CHROME_SERVICE_SERVICE_IPC_SERVER_H_ |
6 #define CHROME_SERVICE_SERVICE_IPC_SERVER_H_ | 6 #define CHROME_SERVICE_SERVICE_IPC_SERVER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
| 12 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
12 #include "ipc/ipc_channel_handle.h" | 15 #include "ipc/ipc_channel_handle.h" |
13 #include "ipc/ipc_listener.h" | 16 #include "ipc/ipc_listener.h" |
| 17 #include "ipc/ipc_sender.h" |
14 #include "ipc/ipc_sync_channel.h" | 18 #include "ipc/ipc_sync_channel.h" |
15 #include "ipc/ipc_sender.h" | |
16 | 19 |
17 namespace base { | 20 namespace base { |
18 | 21 |
19 class HistogramDeltaSerialization; | 22 class HistogramDeltaSerialization; |
20 class WaitableEvent; | 23 class WaitableEvent; |
21 | 24 |
22 } // namespace base | 25 } // namespace base |
23 | 26 |
24 // This class handles IPC commands for the service process. | 27 // This class handles IPC commands for the service process. |
25 class ServiceIPCServer : public IPC::Listener, public IPC::Sender { | 28 class ServiceIPCServer : public IPC::Listener, public IPC::Sender { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 void AddMessageHandler(scoped_ptr<MessageHandler> handler); | 68 void AddMessageHandler(scoped_ptr<MessageHandler> handler); |
66 | 69 |
67 bool is_ipc_client_connected() const { return ipc_client_connected_; } | 70 bool is_ipc_client_connected() const { return ipc_client_connected_; } |
68 | 71 |
69 private: | 72 private: |
70 friend class ServiceIPCServerTest; | 73 friend class ServiceIPCServerTest; |
71 friend class MockServiceIPCServer; | 74 friend class MockServiceIPCServer; |
72 | 75 |
73 // IPC::Listener implementation. | 76 // IPC::Listener implementation. |
74 bool OnMessageReceived(const IPC::Message& msg) override; | 77 bool OnMessageReceived(const IPC::Message& msg) override; |
75 void OnChannelConnected(int32 peer_pid) override; | 78 void OnChannelConnected(int32_t peer_pid) override; |
76 void OnChannelError() override; | 79 void OnChannelError() override; |
77 | 80 |
78 // IPC message handlers. | 81 // IPC message handlers. |
79 void OnGetHistograms(); | 82 void OnGetHistograms(); |
80 void OnShutdown(); | 83 void OnShutdown(); |
81 void OnUpdateAvailable(); | 84 void OnUpdateAvailable(); |
82 | 85 |
83 // Helper method to create the sync channel. | 86 // Helper method to create the sync channel. |
84 void CreateChannel(); | 87 void CreateChannel(); |
85 | 88 |
86 Client* client_; | 89 Client* client_; |
87 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 90 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
88 IPC::ChannelHandle channel_handle_; | 91 IPC::ChannelHandle channel_handle_; |
89 scoped_ptr<IPC::SyncChannel> channel_; | 92 scoped_ptr<IPC::SyncChannel> channel_; |
90 base::WaitableEvent* shutdown_event_; | 93 base::WaitableEvent* shutdown_event_; |
91 ScopedVector<MessageHandler> message_handlers_; | 94 ScopedVector<MessageHandler> message_handlers_; |
92 | 95 |
93 // Indicates whether an IPC client is currently connected to the channel. | 96 // Indicates whether an IPC client is currently connected to the channel. |
94 bool ipc_client_connected_; | 97 bool ipc_client_connected_; |
95 | 98 |
96 // Calculates histograms deltas. | 99 // Calculates histograms deltas. |
97 scoped_ptr<base::HistogramDeltaSerialization> histogram_delta_serializer_; | 100 scoped_ptr<base::HistogramDeltaSerialization> histogram_delta_serializer_; |
98 | 101 |
99 DISALLOW_COPY_AND_ASSIGN(ServiceIPCServer); | 102 DISALLOW_COPY_AND_ASSIGN(ServiceIPCServer); |
100 }; | 103 }; |
101 | 104 |
102 #endif // CHROME_SERVICE_SERVICE_IPC_SERVER_H_ | 105 #endif // CHROME_SERVICE_SERVICE_IPC_SERVER_H_ |
OLD | NEW |