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

Side by Side Diff: extensions/browser/api/idle/idle_manager.cc

Issue 1201063002: Set up the infrastructure for Extension event metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaaaaase Created 5 years, 6 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/api/idle/idle_manager.h" 5 #include "extensions/browser/api/idle/idle_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 : context_(context) { 42 : context_(context) {
43 } 43 }
44 44
45 DefaultEventDelegate::~DefaultEventDelegate() { 45 DefaultEventDelegate::~DefaultEventDelegate() {
46 } 46 }
47 47
48 void DefaultEventDelegate::OnStateChanged(const std::string& extension_id, 48 void DefaultEventDelegate::OnStateChanged(const std::string& extension_id,
49 ui::IdleState new_state) { 49 ui::IdleState new_state) {
50 scoped_ptr<base::ListValue> args(new base::ListValue()); 50 scoped_ptr<base::ListValue> args(new base::ListValue());
51 args->Append(IdleManager::CreateIdleValue(new_state)); 51 args->Append(IdleManager::CreateIdleValue(new_state));
52 scoped_ptr<Event> event( 52 scoped_ptr<Event> event(new Event(
53 new Event(idle::OnStateChanged::kEventName, args.Pass())); 53 events::UNKNOWN, idle::OnStateChanged::kEventName, args.Pass()));
54 event->restrict_to_browser_context = context_; 54 event->restrict_to_browser_context = context_;
55 EventRouter::Get(context_) 55 EventRouter::Get(context_)
56 ->DispatchEventToExtension(extension_id, event.Pass()); 56 ->DispatchEventToExtension(extension_id, event.Pass());
57 } 57 }
58 58
59 void DefaultEventDelegate::RegisterObserver(EventRouter::Observer* observer) { 59 void DefaultEventDelegate::RegisterObserver(EventRouter::Observer* observer) {
60 EventRouter::Get(context_) 60 EventRouter::Get(context_)
61 ->RegisterObserver(observer, idle::OnStateChanged::kEventName); 61 ->RegisterObserver(observer, idle::OnStateChanged::kEventName);
62 } 62 }
63 63
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 event_delegate_->OnStateChanged(it->first, new_state); 253 event_delegate_->OnStateChanged(it->first, new_state);
254 monitor.last_state = new_state; 254 monitor.last_state = new_state;
255 listener_count += monitor.listeners; 255 listener_count += monitor.listeners;
256 } 256 }
257 257
258 if (listener_count == 0) 258 if (listener_count == 0)
259 StopPolling(); 259 StopPolling();
260 } 260 }
261 261
262 } // namespace extensions 262 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/hid/hid_device_manager.cc ('k') | extensions/browser/api/management/management_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698