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

Side by Side Diff: extensions/browser/api/app_runtime/app_runtime_api.cc

Issue 1201063002: Set up the infrastructure for Extension event metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert test JS change 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/app_runtime/app_runtime_api.h" 5 #include "extensions/browser/api/app_runtime/app_runtime_api.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "extensions/browser/event_router.h" 10 #include "extensions/browser/event_router.h"
(...skipping 12 matching lines...) Expand all
23 namespace app_runtime = core_api::app_runtime; 23 namespace app_runtime = core_api::app_runtime;
24 24
25 namespace { 25 namespace {
26 26
27 void DispatchOnEmbedRequestedEventImpl( 27 void DispatchOnEmbedRequestedEventImpl(
28 const std::string& extension_id, 28 const std::string& extension_id,
29 scoped_ptr<base::DictionaryValue> app_embedding_request_data, 29 scoped_ptr<base::DictionaryValue> app_embedding_request_data,
30 content::BrowserContext* context) { 30 content::BrowserContext* context) {
31 scoped_ptr<base::ListValue> args(new base::ListValue()); 31 scoped_ptr<base::ListValue> args(new base::ListValue());
32 args->Append(app_embedding_request_data.release()); 32 args->Append(app_embedding_request_data.release());
33 scoped_ptr<Event> event( 33 scoped_ptr<Event> event(new Event(
34 new Event(app_runtime::OnEmbedRequested::kEventName, args.Pass())); 34 events::UNKNOWN, app_runtime::OnEmbedRequested::kEventName, args.Pass()));
35 event->restrict_to_browser_context = context; 35 event->restrict_to_browser_context = context;
36 EventRouter::Get(context) 36 EventRouter::Get(context)
37 ->DispatchEventWithLazyListener(extension_id, event.Pass()); 37 ->DispatchEventWithLazyListener(extension_id, event.Pass());
38 38
39 ExtensionPrefs::Get(context) 39 ExtensionPrefs::Get(context)
40 ->SetLastLaunchTime(extension_id, base::Time::Now()); 40 ->SetLastLaunchTime(extension_id, base::Time::Now());
41 } 41 }
42 42
43 void DispatchOnLaunchedEventImpl(const std::string& extension_id, 43 void DispatchOnLaunchedEventImpl(const std::string& extension_id,
44 app_runtime::LaunchSource source, 44 app_runtime::LaunchSource source,
45 scoped_ptr<base::DictionaryValue> launch_data, 45 scoped_ptr<base::DictionaryValue> launch_data,
46 BrowserContext* context) { 46 BrowserContext* context) {
47 UMA_HISTOGRAM_ENUMERATION( 47 UMA_HISTOGRAM_ENUMERATION(
48 "Extensions.AppLaunchSource", source, NUM_APP_LAUNCH_SOURCES); 48 "Extensions.AppLaunchSource", source, NUM_APP_LAUNCH_SOURCES);
49 49
50 // "Forced app mode" is true for Chrome OS kiosk mode. 50 // "Forced app mode" is true for Chrome OS kiosk mode.
51 launch_data->SetBoolean( 51 launch_data->SetBoolean(
52 "isKioskSession", 52 "isKioskSession",
53 ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()); 53 ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode());
54 scoped_ptr<base::ListValue> args(new base::ListValue()); 54 scoped_ptr<base::ListValue> args(new base::ListValue());
55 args->Append(launch_data.release()); 55 args->Append(launch_data.release());
56 scoped_ptr<Event> event( 56 scoped_ptr<Event> event(new Event(
57 new Event(app_runtime::OnLaunched::kEventName, args.Pass())); 57 events::UNKNOWN, app_runtime::OnLaunched::kEventName, args.Pass()));
58 event->restrict_to_browser_context = context; 58 event->restrict_to_browser_context = context;
59 EventRouter::Get(context) 59 EventRouter::Get(context)
60 ->DispatchEventWithLazyListener(extension_id, event.Pass()); 60 ->DispatchEventWithLazyListener(extension_id, event.Pass());
61 ExtensionPrefs::Get(context) 61 ExtensionPrefs::Get(context)
62 ->SetLastLaunchTime(extension_id, base::Time::Now()); 62 ->SetLastLaunchTime(extension_id, base::Time::Now());
63 } 63 }
64 64
65 app_runtime::LaunchSource getLaunchSourceEnum( 65 app_runtime::LaunchSource getLaunchSourceEnum(
66 extensions::AppLaunchSource source) { 66 extensions::AppLaunchSource source) {
67 switch (source) { 67 switch (source) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 131 }
132 DispatchOnLaunchedEventImpl( 132 DispatchOnLaunchedEventImpl(
133 extension->id(), source_enum, launch_data.ToValue().Pass(), context); 133 extension->id(), source_enum, launch_data.ToValue().Pass(), context);
134 } 134 }
135 135
136 // static 136 // static
137 void AppRuntimeEventRouter::DispatchOnRestartedEvent( 137 void AppRuntimeEventRouter::DispatchOnRestartedEvent(
138 BrowserContext* context, 138 BrowserContext* context,
139 const Extension* extension) { 139 const Extension* extension) {
140 scoped_ptr<base::ListValue> arguments(new base::ListValue()); 140 scoped_ptr<base::ListValue> arguments(new base::ListValue());
141 scoped_ptr<Event> event( 141 scoped_ptr<Event> event(new Event(
142 new Event(app_runtime::OnRestarted::kEventName, arguments.Pass())); 142 events::UNKNOWN, app_runtime::OnRestarted::kEventName, arguments.Pass()));
143 event->restrict_to_browser_context = context; 143 event->restrict_to_browser_context = context;
144 EventRouter::Get(context) 144 EventRouter::Get(context)
145 ->DispatchEventToExtension(extension->id(), event.Pass()); 145 ->DispatchEventToExtension(extension->id(), event.Pass());
146 } 146 }
147 147
148 // static 148 // static
149 void AppRuntimeEventRouter::DispatchOnLaunchedEventWithFileEntries( 149 void AppRuntimeEventRouter::DispatchOnLaunchedEventWithFileEntries(
150 BrowserContext* context, 150 BrowserContext* context,
151 const Extension* extension, 151 const Extension* extension,
152 const std::string& handler_id, 152 const std::string& handler_id,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 launch_data.url.reset(new std::string(url.spec())); 193 launch_data.url.reset(new std::string(url.spec()));
194 launch_data.referrer_url.reset(new std::string(referrer_url.spec())); 194 launch_data.referrer_url.reset(new std::string(referrer_url.spec()));
195 if (extensions::FeatureSwitch::trace_app_source()->IsEnabled()) { 195 if (extensions::FeatureSwitch::trace_app_source()->IsEnabled()) {
196 launch_data.source = source_enum; 196 launch_data.source = source_enum;
197 } 197 }
198 DispatchOnLaunchedEventImpl( 198 DispatchOnLaunchedEventImpl(
199 extension->id(), source_enum, launch_data.ToValue().Pass(), context); 199 extension->id(), source_enum, launch_data.ToValue().Pass(), context);
200 } 200 }
201 201
202 } // namespace extensions 202 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698