| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/mojo/mojo_application_host.h" | 5 #include "content/browser/mojo/mojo_application_host.h" |
| 6 | 6 |
| 7 #include "content/common/mojo/mojo_messages.h" | 7 #include "content/common/mojo/mojo_messages.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "ipc/ipc_sender.h" | 9 #include "ipc/ipc_sender.h" |
| 10 |
| 11 #if defined(USE_CHROME_EDK) |
| 12 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 13 #else |
| 10 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" | 14 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" |
| 15 #endif |
| 11 | 16 |
| 12 namespace content { | 17 namespace content { |
| 13 namespace { | 18 namespace { |
| 14 | 19 |
| 20 #if defined(USE_CHROME_EDK) |
| 21 base::PlatformFile PlatformFileFromScopedPlatformHandle( |
| 22 mojo::edk::ScopedPlatformHandle handle) { |
| 23 #if defined(OS_POSIX) |
| 24 return handle.release().fd; |
| 25 #elif defined(OS_WIN) |
| 26 return handle.release().handle; |
| 27 #endif |
| 28 } |
| 29 #else |
| 15 base::PlatformFile PlatformFileFromScopedPlatformHandle( | 30 base::PlatformFile PlatformFileFromScopedPlatformHandle( |
| 16 mojo::embedder::ScopedPlatformHandle handle) { | 31 mojo::embedder::ScopedPlatformHandle handle) { |
| 17 #if defined(OS_POSIX) | 32 #if defined(OS_POSIX) |
| 18 return handle.release().fd; | 33 return handle.release().fd; |
| 19 #elif defined(OS_WIN) | 34 #elif defined(OS_WIN) |
| 20 return handle.release().handle; | 35 return handle.release().handle; |
| 21 #endif | 36 #endif |
| 22 } | 37 } |
| 38 #endif |
| 23 | 39 |
| 24 class ApplicationSetupImpl : public ApplicationSetup { | 40 class ApplicationSetupImpl : public ApplicationSetup { |
| 25 public: | 41 public: |
| 26 ApplicationSetupImpl(ServiceRegistryImpl* service_registry, | 42 ApplicationSetupImpl(ServiceRegistryImpl* service_registry, |
| 27 mojo::InterfaceRequest<ApplicationSetup> request) | 43 mojo::InterfaceRequest<ApplicationSetup> request) |
| 28 : binding_(this, request.Pass()), | 44 : binding_(this, request.Pass()), |
| 29 service_registry_(service_registry) { | 45 service_registry_(service_registry) { |
| 30 } | 46 } |
| 31 | 47 |
| 32 ~ApplicationSetupImpl() override { | 48 ~ApplicationSetupImpl() override { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 53 service_registry_android_.reset( | 69 service_registry_android_.reset( |
| 54 new ServiceRegistryAndroid(&service_registry_)); | 70 new ServiceRegistryAndroid(&service_registry_)); |
| 55 #endif | 71 #endif |
| 56 } | 72 } |
| 57 | 73 |
| 58 MojoApplicationHost::~MojoApplicationHost() { | 74 MojoApplicationHost::~MojoApplicationHost() { |
| 59 } | 75 } |
| 60 | 76 |
| 61 bool MojoApplicationHost::Init() { | 77 bool MojoApplicationHost::Init() { |
| 62 DCHECK(!client_handle_.is_valid()) << "Already initialized!"; | 78 DCHECK(!client_handle_.is_valid()) << "Already initialized!"; |
| 63 | 79 #if defined(USE_CHROME_EDK) |
| 80 mojo::edk::PlatformChannelPair channel_pair; |
| 81 #else |
| 64 mojo::embedder::PlatformChannelPair channel_pair; | 82 mojo::embedder::PlatformChannelPair channel_pair; |
| 83 #endif |
| 65 | 84 |
| 66 scoped_refptr<base::TaskRunner> io_task_runner; | 85 scoped_refptr<base::TaskRunner> io_task_runner; |
| 67 if (io_task_runner_override_) { | 86 if (io_task_runner_override_) { |
| 68 io_task_runner = io_task_runner_override_; | 87 io_task_runner = io_task_runner_override_; |
| 69 } else { | 88 } else { |
| 70 io_task_runner = | 89 io_task_runner = |
| 71 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) | 90 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) |
| 72 ->task_runner(); | 91 ->task_runner(); |
| 73 } | 92 } |
| 74 | 93 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 125 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 107 channel_init_.ShutdownOnIOThread(); | 126 channel_init_.ShutdownOnIOThread(); |
| 108 } | 127 } |
| 109 | 128 |
| 110 void MojoApplicationHost::OverrideIOTaskRunnerForTest( | 129 void MojoApplicationHost::OverrideIOTaskRunnerForTest( |
| 111 scoped_refptr<base::TaskRunner> io_task_runner) { | 130 scoped_refptr<base::TaskRunner> io_task_runner) { |
| 112 io_task_runner_override_ = io_task_runner; | 131 io_task_runner_override_ = io_task_runner; |
| 113 } | 132 } |
| 114 | 133 |
| 115 } // namespace content | 134 } // namespace content |
| OLD | NEW |