diff options
author | reillyg <reillyg@chromium.org> | 2015-08-28 16:08:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-28 23:08:46 +0000 |
commit | badbc5415c4cd4d4870b2ca2122b1b9988e341d7 (patch) | |
tree | 154dd8ff7ab4edd48de2921b43f1316849311f4c /extensions/shell | |
parent | e7bcbf464b505face0ed490930f9ba4bbb24ed6c (diff) | |
download | chromium_src-badbc5415c4cd4d4870b2ca2122b1b9988e341d7.zip chromium_src-badbc5415c4cd4d4870b2ca2122b1b9988e341d7.tar.gz chromium_src-badbc5415c4cd4d4870b2ca2122b1b9988e341d7.tar.bz2 |
Manage UsbService lifetime in DeviceClient implementations.
To make it easier to reason about when the UsbService is destroyed this
patch makes its lifetime managed by the DeviceClient implementation that
created it. This means that in Chrome the UsbService is (indirectly)
owned by BrowserProcessImpl.
BUG=None
TBR=dgozman@chromium.org
Review URL: https://codereview.chromium.org/1314273002
Cr-Commit-Position: refs/heads/master@{#346264}
Diffstat (limited to 'extensions/shell')
-rw-r--r-- | extensions/shell/browser/shell_device_client.cc | 8 | ||||
-rw-r--r-- | extensions/shell/browser/shell_device_client.h | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/extensions/shell/browser/shell_device_client.cc b/extensions/shell/browser/shell_device_client.cc index 5dd1c6b..ae00666 100644 --- a/extensions/shell/browser/shell_device_client.cc +++ b/extensions/shell/browser/shell_device_client.cc @@ -19,8 +19,12 @@ ShellDeviceClient::~ShellDeviceClient() {} device::UsbService* ShellDeviceClient::GetUsbService() { DCHECK_CURRENTLY_ON(BrowserThread::UI); - return device::UsbService::GetInstance( - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); + + if (!usb_service_) { + usb_service_ = device::UsbService::Create( + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); + } + return usb_service_.get(); } device::HidService* ShellDeviceClient::GetHidService() { diff --git a/extensions/shell/browser/shell_device_client.h b/extensions/shell/browser/shell_device_client.h index b3bec78..5f4ebd7 100644 --- a/extensions/shell/browser/shell_device_client.h +++ b/extensions/shell/browser/shell_device_client.h @@ -9,6 +9,7 @@ #include "base/compiler_specific.h" #include "base/macros.h" +#include "base/memory/scoped_ptr.h" namespace extensions { @@ -24,6 +25,8 @@ class ShellDeviceClient : device::DeviceClient { device::HidService* GetHidService() override; private: + scoped_ptr<device::UsbService> usb_service_; + DISALLOW_COPY_AND_ASSIGN(ShellDeviceClient); }; |