Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3590)

Unified Diff: device/hid/hid_service.cc

Issue 161823002: Clean up HID backend and API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: linux headers Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/hid/hid_service.cc
diff --git a/device/hid/hid_service.cc b/device/hid/hid_service.cc
index 973e901a82b8a77b12388c906954ee5ea2eeac27..39a53708ffa67994a37eed3a804f36b1e20a31cc 100644
--- a/device/hid/hid_service.cc
+++ b/device/hid/hid_service.cc
@@ -1,18 +1,13 @@
-// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// 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 "device/hid/hid_service.h"
-#include <vector>
-
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/scoped_vector.h"
-#include "base/message_loop/message_loop.h"
#include "base/threading/thread_restrictions.h"
-#include "build/build_config.h"
-#include "device/hid/hid_device_info.h"
#if defined(OS_LINUX)
#include "device/hid/hid_service_linux.h"
@@ -32,7 +27,7 @@ base::LazyInstance<scoped_ptr<HidService> >::Leaky g_hid_service_ptr =
} // namespace
-HidService::HidService() : initialized_(false) {
+HidService::HidService() {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(thread_checker_.CalledOnValidThread());
base::MessageLoop::current()->AddDestructionObserver(this);
@@ -59,7 +54,8 @@ void HidService::GetDevices(std::vector<HidDeviceInfo>* devices) {
}
// Fills in the device info struct of the given device_id.
-bool HidService::GetInfo(std::string device_id, HidDeviceInfo* info) const {
+bool HidService::GetInfo(const std::string& device_id,
+ HidDeviceInfo* info) const {
DeviceMap::const_iterator it = devices_.find(device_id);
if (it == devices_.end())
return false;
@@ -74,7 +70,7 @@ void HidService::AddDevice(HidDeviceInfo info) {
}
}
-void HidService::RemoveDevice(std::string device_id) {
+void HidService::RemoveDevice(const std::string& device_id) {
if (ContainsKey(devices_, device_id)) {
DCHECK(thread_checker_.CalledOnValidThread());
devices_.erase(device_id);
@@ -94,12 +90,8 @@ HidService* HidService::CreateInstance() {
}
HidService* HidService::GetInstance() {
- if (!g_hid_service_ptr.Get().get()){
- scoped_ptr<HidService> service(CreateInstance());
-
- if (service && service->initialized())
- g_hid_service_ptr.Get().reset(service.release());
- }
+ if (!g_hid_service_ptr.Get().get())
+ g_hid_service_ptr.Get().reset(CreateInstance());
return g_hid_service_ptr.Get().get();
}

Powered by Google App Engine
This is Rietveld 408576698