| Index: chrome/browser/extensions/system_info_watcher.cc
|
| diff --git a/chrome/browser/extensions/system_info_watcher.cc b/chrome/browser/extensions/system_info_watcher.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..611a6246e62d70c64544f0c4175e0cf4256cd916
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/system_info_watcher.cc
|
| @@ -0,0 +1,56 @@
|
| +// Copyright (c) 2012 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 "chrome/browser/extensions/system_info_watcher.h"
|
| +
|
| +#include "base/logging.h"
|
| +
|
| +namespace extensions {
|
| +
|
| +SystemInfoWatcher::SystemInfoWatcher() {
|
| +}
|
| +
|
| +SystemInfoWatcher::~SystemInfoWatcher() {
|
| +}
|
| +
|
| +// static
|
| +void SystemInfoWatcher::InitializeForTesting(SystemInfoWatcher* watcher) {
|
| + DCHECK(watcher);
|
| + single_shared_watcher_.Get().reset(watcher);
|
| +}
|
| +
|
| +void SystemInfoWatcher::AddObserver(Observer* observer) {
|
| + DCHECK(observer);
|
| + observers_.AddObserver(observer);
|
| +}
|
| +
|
| +void SystemInfoWatcher::RemoveObserver(Observer* observer) {
|
| + DCHECK(observer);
|
| + observers_.RemoveObserver(observer);
|
| +}
|
| +
|
| +bool SystemInfoWatcher::StartWatching(const std::string& event_name) {
|
| + if (IsWatching(event_name))
|
| + return true;
|
| + return PlatformStartWatching(event_name);
|
| +}
|
| +
|
| +bool SystemInfoWatcher::StopWatching(const std::string& event_name) {
|
| + bool success = true;
|
| + if (IsWatching(event_name)) {
|
| + success = PlatformStopWatching(event_name);
|
| + watching_event_names_.erase(event_name);
|
| + }
|
| + return success;
|
| +}
|
| +
|
| +bool SystemInfoWatcher::IsWatching(const std::string& event_name) {
|
| + return watching_event_names_.find(event_name) != watching_event_names_.end();
|
| +}
|
| +
|
| +// The single shared instance initialization.
|
| +base::LazyInstance<scoped_ptr<SystemInfoWatcher> >
|
| + SystemInfoWatcher::single_shared_watcher_ = LAZY_INSTANCE_INITIALIZER;
|
| +
|
| +} // namespace extensions
|
|
|