summaryrefslogtreecommitdiffstats
path: root/extensions/shell
diff options
context:
space:
mode:
authorrockot <rockot@chromium.org>2014-09-05 01:02:44 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-05 08:05:55 +0000
commit1a51b92b7038b82a90c1a1944104eaf8c51a9e1c (patch)
tree9dde79f2e12d64897300d2c389725ab4d349f01f /extensions/shell
parent243eec86f415a6624d8d41b0ea0393eda0b3a808 (diff)
downloadchromium_src-1a51b92b7038b82a90c1a1944104eaf8c51a9e1c.zip
chromium_src-1a51b92b7038b82a90c1a1944104eaf8c51a9e1c.tar.gz
chromium_src-1a51b92b7038b82a90c1a1944104eaf8c51a9e1c.tar.bz2
Fix HidService lifetime issues
This reverts HidService to being a singleton instance for now. BUG=401234 TBR=rpaquay Review URL: https://codereview.chromium.org/523743005 Cr-Commit-Position: refs/heads/master@{#293464}
Diffstat (limited to 'extensions/shell')
-rw-r--r--extensions/shell/app_shell.gyp2
-rw-r--r--extensions/shell/browser/api/shell_extensions_api_client.cc27
-rw-r--r--extensions/shell/browser/api/shell_extensions_api_client.h28
-rw-r--r--extensions/shell/browser/shell_device_client.cc7
-rw-r--r--extensions/shell/browser/shell_device_client.h1
-rw-r--r--extensions/shell/browser/shell_extensions_browser_client.cc4
6 files changed, 10 insertions, 59 deletions
diff --git a/extensions/shell/app_shell.gyp b/extensions/shell/app_shell.gyp
index 0eeb392..a1e00fa 100644
--- a/extensions/shell/app_shell.gyp
+++ b/extensions/shell/app_shell.gyp
@@ -50,8 +50,6 @@
'app/shell_main_delegate.h',
'browser/api/shell/shell_api.cc',
'browser/api/shell/shell_api.h',
- 'browser/api/shell_extensions_api_client.cc',
- 'browser/api/shell_extensions_api_client.h',
'browser/default_shell_browser_main_delegate.cc',
'browser/default_shell_browser_main_delegate.h',
'browser/desktop_controller.cc',
diff --git a/extensions/shell/browser/api/shell_extensions_api_client.cc b/extensions/shell/browser/api/shell_extensions_api_client.cc
deleted file mode 100644
index a8e7d11..0000000
--- a/extensions/shell/browser/api/shell_extensions_api_client.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "extensions/shell/browser/api/shell_extensions_api_client.h"
-
-#include "content/public/browser/browser_thread.h"
-#include "device/hid/hid_service.h"
-
-namespace extensions {
-
-ShellExtensionsAPIClient::ShellExtensionsAPIClient() {
-}
-
-ShellExtensionsAPIClient::~ShellExtensionsAPIClient() {
-}
-
-device::HidService* ShellExtensionsAPIClient::GetHidService() {
- if (!hid_service_) {
- hid_service_.reset(device::HidService::Create(
- content::BrowserThread::GetMessageLoopProxyForThread(
- content::BrowserThread::UI)));
- }
- return hid_service_.get();
-}
-
-} // namespace extensions
diff --git a/extensions/shell/browser/api/shell_extensions_api_client.h b/extensions/shell/browser/api/shell_extensions_api_client.h
deleted file mode 100644
index 41f548f..0000000
--- a/extensions/shell/browser/api/shell_extensions_api_client.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef EXTENSIONS_SHELL_BROWSER_API_SHELL_EXTENSIONS_API_CLIENT_H_
-#define EXTENSIONS_SHELL_BROWSER_API_SHELL_EXTENSIONS_API_CLIENT_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "extensions/browser/api/extensions_api_client.h"
-
-namespace extensions {
-
-// Extra support for Chrome extensions APIs in app_shell.
-class ShellExtensionsAPIClient : public ExtensionsAPIClient {
- public:
- ShellExtensionsAPIClient();
- virtual ~ShellExtensionsAPIClient();
-
- // ExtensionsAPIClient implementation.
- virtual device::HidService* GetHidService() OVERRIDE;
-
- private:
- scoped_ptr<device::HidService> hid_service_;
-};
-
-} // namespace extensions
-
-#endif // EXTENSIONS_SHELL_BROWSER_API_SHELL_EXTENSIONS_API_CLIENT_H_
diff --git a/extensions/shell/browser/shell_device_client.cc b/extensions/shell/browser/shell_device_client.cc
index b3c8168..55b277b 100644
--- a/extensions/shell/browser/shell_device_client.cc
+++ b/extensions/shell/browser/shell_device_client.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "content/public/browser/browser_thread.h"
+#include "device/hid/hid_service.h"
#include "device/usb/usb_service.h"
namespace extensions {
@@ -20,4 +21,10 @@ device::UsbService* ShellDeviceClient::GetUsbService() {
content::BrowserThread::UI));
}
+device::HidService* ShellDeviceClient::GetHidService() {
+ return device::HidService::GetInstance(
+ content::BrowserThread::GetMessageLoopProxyForThread(
+ content::BrowserThread::UI));
+}
+
}
diff --git a/extensions/shell/browser/shell_device_client.h b/extensions/shell/browser/shell_device_client.h
index 862d609..c1ede48 100644
--- a/extensions/shell/browser/shell_device_client.h
+++ b/extensions/shell/browser/shell_device_client.h
@@ -21,6 +21,7 @@ class ShellDeviceClient : device::DeviceClient {
// device::DeviceClient implementation
virtual device::UsbService* GetUsbService() OVERRIDE;
+ virtual device::HidService* GetHidService() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(ShellDeviceClient);
diff --git a/extensions/shell/browser/shell_extensions_browser_client.cc b/extensions/shell/browser/shell_extensions_browser_client.cc
index 84e757c..659f88f 100644
--- a/extensions/shell/browser/shell_extensions_browser_client.cc
+++ b/extensions/shell/browser/shell_extensions_browser_client.cc
@@ -9,12 +9,12 @@
#include "base/prefs/testing_pref_store.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/user_prefs/user_prefs.h"
+#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/api/generated_api_registration.h"
#include "extensions/browser/app_sorting.h"
#include "extensions/browser/extension_function_registry.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/shell/browser/api/generated_api_registration.h"
-#include "extensions/shell/browser/api/shell_extensions_api_client.h"
#include "extensions/shell/browser/shell_app_sorting.h"
#include "extensions/shell/browser/shell_extension_host_delegate.h"
#include "extensions/shell/browser/shell_extension_system_factory.h"
@@ -34,7 +34,7 @@ void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry) {
ShellExtensionsBrowserClient::ShellExtensionsBrowserClient(
BrowserContext* context)
- : browser_context_(context), api_client_(new ShellExtensionsAPIClient) {
+ : browser_context_(context), api_client_(new ExtensionsAPIClient) {
// Set up the preferences service.
base::PrefServiceFactory factory;
factory.set_user_prefs(new TestingPrefStore);