| 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 "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/common/service_messages.h" | 9 #include "chrome/common/service_messages.h" |
| 10 #include "ipc/ipc_channel_mojo.h" | 10 #include "ipc/ipc_channel_mojo.h" |
| 11 #include "ipc/ipc_logging.h" | 11 #include "ipc/ipc_logging.h" |
| 12 | 12 |
| 13 ServiceIPCServer::ServiceIPCServer( | 13 ServiceIPCServer::ServiceIPCServer( |
| 14 Client* client, | 14 Client* client, |
| 15 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 15 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| 16 base::WaitableEvent* shutdown_event) | 16 base::WaitableEvent* shutdown_event) |
| 17 : client_(client), | 17 : client_(client), |
| 18 io_task_runner_(io_task_runner), | 18 io_task_runner_(io_task_runner), |
| 19 shutdown_event_(shutdown_event) { | 19 shutdown_event_(shutdown_event) { |
| 20 DCHECK(client); | 20 DCHECK(client); |
| 21 DCHECK(shutdown_event); | 21 DCHECK(shutdown_event); |
| 22 } | 22 } |
| 23 | 23 |
| 24 bool ServiceIPCServer::Init() { | 24 bool ServiceIPCServer::Init() { |
| 25 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) | 25 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 26 IPC::Logging::GetInstance()->SetIPCSender(this); | 26 IPC::Logging::GetInstance()->SetIPCSender(this); |
| 27 #endif | 27 #endif |
| 28 CreateChannel(); | 28 CreateChannel(); |
| 29 return true; | 29 return true; |
| 30 } | 30 } |
| 31 | 31 |
| 32 void ServiceIPCServer::CreateChannel() { | 32 void ServiceIPCServer::CreateChannel() { |
| 33 channel_.reset(); // Tear down the existing channel, if any. | 33 channel_.reset(); // Tear down the existing channel, if any. |
| 34 channel_ = IPC::SyncChannel::Create( | 34 channel_ = IPC::SyncChannel::Create( |
| 35 IPC::ChannelMojo::CreateServerFactory(client_->CreateChannelMessagePipe(), | 35 IPC::ChannelMojo::CreateServerFactory(client_->CreateChannelMessagePipe(), |
| 36 io_task_runner_), | 36 io_task_runner_), |
| 37 this /* listener */, io_task_runner_, true /* create_pipe_now */, | 37 this /* listener */, io_task_runner_, true /* create_pipe_now */, |
| 38 shutdown_event_); | 38 shutdown_event_); |
| 39 } | 39 } |
| 40 | 40 |
| 41 ServiceIPCServer::~ServiceIPCServer() { | 41 ServiceIPCServer::~ServiceIPCServer() { |
| 42 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) | 42 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 43 IPC::Logging::GetInstance()->SetIPCSender(NULL); | 43 IPC::Logging::GetInstance()->SetIPCSender(NULL); |
| 44 #endif | 44 #endif |
| 45 } | 45 } |
| 46 | 46 |
| 47 void ServiceIPCServer::OnChannelConnected(int32_t peer_pid) { | 47 void ServiceIPCServer::OnChannelConnected(int32_t peer_pid) { |
| 48 DCHECK(!ipc_client_connected_); | 48 DCHECK(!ipc_client_connected_); |
| 49 ipc_client_connected_ = true; | 49 ipc_client_connected_ = true; |
| 50 } | 50 } |
| 51 | 51 |
| 52 void ServiceIPCServer::OnChannelError() { | 52 void ServiceIPCServer::OnChannelError() { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 channel_->Send(new ServiceHostMsg_Histograms(deltas)); | 114 channel_->Send(new ServiceHostMsg_Histograms(deltas)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ServiceIPCServer::OnShutdown() { | 117 void ServiceIPCServer::OnShutdown() { |
| 118 client_->OnShutdown(); | 118 client_->OnShutdown(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void ServiceIPCServer::OnUpdateAvailable() { | 121 void ServiceIPCServer::OnUpdateAvailable() { |
| 122 client_->OnUpdateAvailable(); | 122 client_->OnUpdateAvailable(); |
| 123 } | 123 } |
| OLD | NEW |