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

Side by Side Diff: chrome/browser/extensions/system_info_watcher.cc

Issue 10836341: Add the basic code skeleton for system info event router (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add mock implementation for onAdded and onRemoved events Created 8 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/system_info_watcher.h"
6
7 #include "base/logging.h"
8
9 namespace extensions {
10
11 SystemInfoWatcher::SystemInfoWatcher() {
12 }
13
14 SystemInfoWatcher::~SystemInfoWatcher() {
15 }
16
17 // static
18 void SystemInfoWatcher::InitializeForTesting(SystemInfoWatcher* watcher) {
19 DCHECK(watcher);
20 single_shared_watcher_.Get().reset(watcher);
21 }
22
23 void SystemInfoWatcher::AddObserver(Observer* observer) {
24 DCHECK(observer);
25 observers_.AddObserver(observer);
26 }
27
28 void SystemInfoWatcher::RemoveObserver(Observer* observer) {
29 DCHECK(observer);
30 observers_.RemoveObserver(observer);
31 }
32
33 bool SystemInfoWatcher::StartWatching(const std::string& event_name) {
34 if (IsWatching(event_name))
35 return true;
36 return PlatformStartWatching(event_name);
37 }
38
39 bool SystemInfoWatcher::StopWatching(const std::string& event_name) {
40 bool success = true;
41 if (IsWatching(event_name)) {
42 success = PlatformStopWatching(event_name);
43 watching_event_names_.erase(event_name);
44 }
45 return success;
46 }
47
48 bool SystemInfoWatcher::IsWatching(const std::string& event_name) {
49 return watching_event_names_.find(event_name) != watching_event_names_.end();
50 }
51
52 // The single shared instance initialization.
53 base::LazyInstance<scoped_ptr<SystemInfoWatcher> >
54 SystemInfoWatcher::single_shared_watcher_ = LAZY_INSTANCE_INITIALIZER;
55
56 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698