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 #include "chrome/service/service_ipc_server.h" | 5 #include "chrome/service/service_ipc_server.h" |
6 | 6 |
7 #include "base/metrics/histogram_delta_serialization.h" | 7 #include "base/metrics/histogram_delta_serialization.h" |
8 #include "chrome/common/service_messages.h" | 8 #include "chrome/common/service_messages.h" |
9 #include "chrome/service/cloud_print/cloud_print_proxy.h" | 9 #include "chrome/service/cloud_print/cloud_print_proxy.h" |
10 #include "chrome/service/service_process.h" | 10 #include "chrome/service/service_process.h" |
11 #include "ipc/ipc_logging.h" | 11 #include "ipc/ipc_logging.h" |
12 | 12 |
13 ServiceIPCServer::ServiceIPCServer(const IPC::ChannelHandle& channel_handle) | 13 ServiceIPCServer::ServiceIPCServer(const IPC::ChannelHandle& channel_handle) |
14 : channel_handle_(channel_handle), client_connected_(false) { | 14 : channel_handle_(channel_handle), client_connected_(false) { |
15 } | 15 } |
16 | 16 |
17 bool ServiceIPCServer::Init() { | 17 bool ServiceIPCServer::Init() { |
18 #ifdef IPC_MESSAGE_LOG_ENABLED | 18 #ifdef IPC_MESSAGE_LOG_ENABLED |
19 IPC::Logging::GetInstance()->SetIPCSender(this); | 19 IPC::Logging::GetInstance()->SetIPCSender(this); |
20 #endif | 20 #endif |
21 sync_message_filter_ = | 21 sync_message_filter_ = |
22 new IPC::SyncMessageFilter(g_service_process->shutdown_event()); | 22 new IPC::SyncMessageFilter(g_service_process->shutdown_event()); |
23 CreateChannel(); | 23 CreateChannel(); |
24 return true; | 24 return true; |
25 } | 25 } |
26 | 26 |
27 void ServiceIPCServer::CreateChannel() { | 27 void ServiceIPCServer::CreateChannel() { |
28 channel_.reset(NULL); // Tear down the existing channel, if any. | 28 channel_.reset(NULL); // Tear down the existing channel, if any. |
29 channel_.reset(new IPC::SyncChannel( | 29 channel_= IPC::SyncChannel::CreateNamedServer( |
30 channel_handle_, | 30 channel_handle_, |
31 IPC::Channel::MODE_NAMED_SERVER, | |
32 this, | 31 this, |
33 g_service_process->io_thread()->message_loop_proxy().get(), | 32 g_service_process->io_thread()->message_loop_proxy().get(), |
34 true, | 33 true, |
35 g_service_process->shutdown_event())); | 34 g_service_process->shutdown_event()); |
36 DCHECK(sync_message_filter_.get()); | 35 DCHECK(sync_message_filter_.get()); |
37 channel_->AddFilter(sync_message_filter_.get()); | 36 channel_->AddFilter(sync_message_filter_.get()); |
38 } | 37 } |
39 | 38 |
40 ServiceIPCServer::~ServiceIPCServer() { | 39 ServiceIPCServer::~ServiceIPCServer() { |
41 #ifdef IPC_MESSAGE_LOG_ENABLED | 40 #ifdef IPC_MESSAGE_LOG_ENABLED |
42 IPC::Logging::GetInstance()->SetIPCSender(NULL); | 41 IPC::Logging::GetInstance()->SetIPCSender(NULL); |
43 #endif | 42 #endif |
44 | 43 |
45 channel_->RemoveFilter(sync_message_filter_.get()); | 44 channel_->RemoveFilter(sync_message_filter_.get()); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 146 } |
148 | 147 |
149 void ServiceIPCServer::OnShutdown() { | 148 void ServiceIPCServer::OnShutdown() { |
150 g_service_process->Shutdown(); | 149 g_service_process->Shutdown(); |
151 } | 150 } |
152 | 151 |
153 void ServiceIPCServer::OnUpdateAvailable() { | 152 void ServiceIPCServer::OnUpdateAvailable() { |
154 g_service_process->SetUpdateAvailable(); | 153 g_service_process->SetUpdateAvailable(); |
155 } | 154 } |
156 | 155 |
OLD | NEW |