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_ = IPC::SyncChannel::Create( | 29 channel_ = IPC::SyncChannel::Create( |
30 channel_handle_, | 30 channel_handle_, IPC::Channel::MODE_NAMED_SERVER, this, |
31 IPC::Channel::MODE_NAMED_SERVER, | 31 g_service_process->io_thread()->task_runner().get(), true, |
32 this, | |
33 g_service_process->io_thread()->message_loop_proxy().get(), | |
34 true, | |
35 g_service_process->shutdown_event()); | 32 g_service_process->shutdown_event()); |
36 DCHECK(sync_message_filter_.get()); | 33 DCHECK(sync_message_filter_.get()); |
37 channel_->AddFilter(sync_message_filter_.get()); | 34 channel_->AddFilter(sync_message_filter_.get()); |
38 } | 35 } |
39 | 36 |
40 ServiceIPCServer::~ServiceIPCServer() { | 37 ServiceIPCServer::~ServiceIPCServer() { |
41 #ifdef IPC_MESSAGE_LOG_ENABLED | 38 #ifdef IPC_MESSAGE_LOG_ENABLED |
42 IPC::Logging::GetInstance()->SetIPCSender(NULL); | 39 IPC::Logging::GetInstance()->SetIPCSender(NULL); |
43 #endif | 40 #endif |
44 | 41 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 144 } |
148 | 145 |
149 void ServiceIPCServer::OnShutdown() { | 146 void ServiceIPCServer::OnShutdown() { |
150 g_service_process->Shutdown(); | 147 g_service_process->Shutdown(); |
151 } | 148 } |
152 | 149 |
153 void ServiceIPCServer::OnUpdateAvailable() { | 150 void ServiceIPCServer::OnUpdateAvailable() { |
154 g_service_process->SetUpdateAvailable(); | 151 g_service_process->SetUpdateAvailable(); |
155 } | 152 } |
156 | 153 |
OLD | NEW |