summaryrefslogtreecommitdiffstats
path: root/extensions/shell
diff options
context:
space:
mode:
authorreillyg <reillyg@chromium.org>2015-08-28 16:41:09 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-28 23:41:46 +0000
commit33338fc038bed55f7f32c0805eee01e2b88f1c13 (patch)
tree6d36e461f00c3b2ec6add6d115fab42d128c77d2 /extensions/shell
parentb77d63131e9648941d484aba04993571eb9c2db7 (diff)
downloadchromium_src-33338fc038bed55f7f32c0805eee01e2b88f1c13.zip
chromium_src-33338fc038bed55f7f32c0805eee01e2b88f1c13.tar.gz
chromium_src-33338fc038bed55f7f32c0805eee01e2b88f1c13.tar.bz2
Manage HidService lifetime in DeviceClient implementations.
To make it easier to reason about when the HidService is destroyed this patch makes its lifetime managed by the DeviceClient implementation that created it. This means that in Chrome the HidService is (indirectly) owned by BrowserProcessImpl. BUG=None Review URL: https://codereview.chromium.org/1312993008 Cr-Commit-Position: refs/heads/master@{#346272}
Diffstat (limited to 'extensions/shell')
-rw-r--r--extensions/shell/browser/shell_device_client.cc7
-rw-r--r--extensions/shell/browser/shell_device_client.h1
2 files changed, 6 insertions, 2 deletions
diff --git a/extensions/shell/browser/shell_device_client.cc b/extensions/shell/browser/shell_device_client.cc
index ae00666..857e2a4 100644
--- a/extensions/shell/browser/shell_device_client.cc
+++ b/extensions/shell/browser/shell_device_client.cc
@@ -29,8 +29,11 @@ device::UsbService* ShellDeviceClient::GetUsbService() {
device::HidService* ShellDeviceClient::GetHidService() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- return device::HidService::GetInstance(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
+ if (!hid_service_) {
+ hid_service_ = device::HidService::Create(
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
+ }
+ return hid_service_.get();
}
}
diff --git a/extensions/shell/browser/shell_device_client.h b/extensions/shell/browser/shell_device_client.h
index 5f4ebd7..2a5e717 100644
--- a/extensions/shell/browser/shell_device_client.h
+++ b/extensions/shell/browser/shell_device_client.h
@@ -25,6 +25,7 @@ class ShellDeviceClient : device::DeviceClient {
device::HidService* GetHidService() override;
private:
+ scoped_ptr<device::HidService> hid_service_;
scoped_ptr<device::UsbService> usb_service_;
DISALLOW_COPY_AND_ASSIGN(ShellDeviceClient);