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