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> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "ipc/ipc_channel_handle.h" | 15 #include "ipc/ipc_channel_handle.h" |
16 #include "ipc/ipc_listener.h" | 16 #include "ipc/ipc_listener.h" |
17 #include "ipc/ipc_sender.h" | 17 #include "ipc/ipc_sender.h" |
18 #include "ipc/ipc_sync_channel.h" | 18 #include "ipc/ipc_sync_channel.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 | 21 |
22 class HistogramDeltaSerialization; | 22 class HistogramDeltaSerialization; |
23 class WaitableEvent; | 23 class WaitableEvent; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 bool Init(); | 59 bool Init(); |
60 | 60 |
61 // IPC::Sender implementation. | 61 // IPC::Sender implementation. |
62 bool Send(IPC::Message* msg) override; | 62 bool Send(IPC::Message* msg) override; |
63 | 63 |
64 // Registers a MessageHandler with the ServiceIPCServer. When an IPC message | 64 // Registers a MessageHandler with the ServiceIPCServer. When an IPC message |
65 // is received that is not handled by the ServiceIPCServer itself, the | 65 // is received that is not handled by the ServiceIPCServer itself, the |
66 // handlers will be called to handle the message in first-add first-call order | 66 // handlers will be called to handle the message in first-add first-call order |
67 // until it is handled or there are no more handlers. | 67 // until it is handled or there are no more handlers. |
68 void AddMessageHandler(scoped_ptr<MessageHandler> handler); | 68 void AddMessageHandler(std::unique_ptr<MessageHandler> handler); |
69 | 69 |
70 bool is_ipc_client_connected() const { return ipc_client_connected_; } | 70 bool is_ipc_client_connected() const { return ipc_client_connected_; } |
71 | 71 |
72 private: | 72 private: |
73 friend class ServiceIPCServerTest; | 73 friend class ServiceIPCServerTest; |
74 friend class MockServiceIPCServer; | 74 friend class MockServiceIPCServer; |
75 | 75 |
76 // IPC::Listener implementation. | 76 // IPC::Listener implementation. |
77 bool OnMessageReceived(const IPC::Message& msg) override; | 77 bool OnMessageReceived(const IPC::Message& msg) override; |
78 void OnChannelConnected(int32_t peer_pid) override; | 78 void OnChannelConnected(int32_t peer_pid) override; |
79 void OnChannelError() override; | 79 void OnChannelError() override; |
80 | 80 |
81 // IPC message handlers. | 81 // IPC message handlers. |
82 void OnGetHistograms(); | 82 void OnGetHistograms(); |
83 void OnShutdown(); | 83 void OnShutdown(); |
84 void OnUpdateAvailable(); | 84 void OnUpdateAvailable(); |
85 | 85 |
86 // Helper method to create the sync channel. | 86 // Helper method to create the sync channel. |
87 void CreateChannel(); | 87 void CreateChannel(); |
88 | 88 |
89 Client* client_; | 89 Client* client_; |
90 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 90 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
91 IPC::ChannelHandle channel_handle_; | 91 IPC::ChannelHandle channel_handle_; |
92 scoped_ptr<IPC::SyncChannel> channel_; | 92 std::unique_ptr<IPC::SyncChannel> channel_; |
93 base::WaitableEvent* shutdown_event_; | 93 base::WaitableEvent* shutdown_event_; |
94 ScopedVector<MessageHandler> message_handlers_; | 94 ScopedVector<MessageHandler> message_handlers_; |
95 | 95 |
96 // Indicates whether an IPC client is currently connected to the channel. | 96 // Indicates whether an IPC client is currently connected to the channel. |
97 bool ipc_client_connected_; | 97 bool ipc_client_connected_; |
98 | 98 |
99 // Calculates histograms deltas. | 99 // Calculates histograms deltas. |
100 scoped_ptr<base::HistogramDeltaSerialization> histogram_delta_serializer_; | 100 std::unique_ptr<base::HistogramDeltaSerialization> |
| 101 histogram_delta_serializer_; |
101 | 102 |
102 DISALLOW_COPY_AND_ASSIGN(ServiceIPCServer); | 103 DISALLOW_COPY_AND_ASSIGN(ServiceIPCServer); |
103 }; | 104 }; |
104 | 105 |
105 #endif // CHROME_SERVICE_SERVICE_IPC_SERVER_H_ | 106 #endif // CHROME_SERVICE_SERVICE_IPC_SERVER_H_ |
OLD | NEW |