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

Side by Side Diff: chrome/browser/extensions/api/image_writer_private/operation_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/lazy_instance.h" 5 #include "base/lazy_instance.h"
6 #include "chrome/browser/browser_process.h" 6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_ operation.h" 7 #include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_ operation.h"
8 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" 8 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h"
9 #include "chrome/browser/extensions/api/image_writer_private/operation.h" 9 #include "chrome/browser/extensions/api/image_writer_private/operation.h"
10 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h " 10 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h "
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 image_writer_api::Stage stage, 153 image_writer_api::Stage stage,
154 int progress) { 154 int progress) {
155 DCHECK_CURRENTLY_ON(BrowserThread::UI); 155 DCHECK_CURRENTLY_ON(BrowserThread::UI);
156 156
157 image_writer_api::ProgressInfo info; 157 image_writer_api::ProgressInfo info;
158 info.stage = stage; 158 info.stage = stage;
159 info.percent_complete = progress; 159 info.percent_complete = progress;
160 160
161 scoped_ptr<base::ListValue> args( 161 scoped_ptr<base::ListValue> args(
162 image_writer_api::OnWriteProgress::Create(info)); 162 image_writer_api::OnWriteProgress::Create(info));
163 scoped_ptr<Event> event(new Event( 163 scoped_ptr<Event> event(
164 image_writer_api::OnWriteProgress::kEventName, args.Pass())); 164 new Event(events::UNKNOWN, image_writer_api::OnWriteProgress::kEventName,
165 args.Pass()));
165 166
166 EventRouter::Get(browser_context_) 167 EventRouter::Get(browser_context_)
167 ->DispatchEventToExtension(extension_id, event.Pass()); 168 ->DispatchEventToExtension(extension_id, event.Pass());
168 } 169 }
169 170
170 void OperationManager::OnComplete(const ExtensionId& extension_id) { 171 void OperationManager::OnComplete(const ExtensionId& extension_id) {
171 DCHECK_CURRENTLY_ON(BrowserThread::UI); 172 DCHECK_CURRENTLY_ON(BrowserThread::UI);
172 173
173 scoped_ptr<base::ListValue> args(image_writer_api::OnWriteComplete::Create()); 174 scoped_ptr<base::ListValue> args(image_writer_api::OnWriteComplete::Create());
174 scoped_ptr<Event> event(new Event( 175 scoped_ptr<Event> event(
175 image_writer_api::OnWriteComplete::kEventName, args.Pass())); 176 new Event(events::UNKNOWN, image_writer_api::OnWriteComplete::kEventName,
177 args.Pass()));
176 178
177 EventRouter::Get(browser_context_) 179 EventRouter::Get(browser_context_)
178 ->DispatchEventToExtension(extension_id, event.Pass()); 180 ->DispatchEventToExtension(extension_id, event.Pass());
179 181
180 DeleteOperation(extension_id); 182 DeleteOperation(extension_id);
181 } 183 }
182 184
183 void OperationManager::OnError(const ExtensionId& extension_id, 185 void OperationManager::OnError(const ExtensionId& extension_id,
184 image_writer_api::Stage stage, 186 image_writer_api::Stage stage,
185 int progress, 187 int progress,
186 const std::string& error_message) { 188 const std::string& error_message) {
187 DCHECK_CURRENTLY_ON(BrowserThread::UI); 189 DCHECK_CURRENTLY_ON(BrowserThread::UI);
188 image_writer_api::ProgressInfo info; 190 image_writer_api::ProgressInfo info;
189 191
190 DLOG(ERROR) << "ImageWriter error: " << error_message; 192 DLOG(ERROR) << "ImageWriter error: " << error_message;
191 193
192 info.stage = stage; 194 info.stage = stage;
193 info.percent_complete = progress; 195 info.percent_complete = progress;
194 196
195 scoped_ptr<base::ListValue> args( 197 scoped_ptr<base::ListValue> args(
196 image_writer_api::OnWriteError::Create(info, error_message)); 198 image_writer_api::OnWriteError::Create(info, error_message));
197 scoped_ptr<Event> event(new Event( 199 scoped_ptr<Event> event(new Event(events::UNKNOWN,
198 image_writer_api::OnWriteError::kEventName, args.Pass())); 200 image_writer_api::OnWriteError::kEventName,
201 args.Pass()));
199 202
200 EventRouter::Get(browser_context_) 203 EventRouter::Get(browser_context_)
201 ->DispatchEventToExtension(extension_id, event.Pass()); 204 ->DispatchEventToExtension(extension_id, event.Pass());
202 205
203 DeleteOperation(extension_id); 206 DeleteOperation(extension_id);
204 } 207 }
205 208
206 Operation* OperationManager::GetOperation(const ExtensionId& extension_id) { 209 Operation* OperationManager::GetOperation(const ExtensionId& extension_id) {
207 OperationMap::iterator existing_operation = operations_.find(extension_id); 210 OperationMap::iterator existing_operation = operations_.find(extension_id);
208 211
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 g_factory = LAZY_INSTANCE_INITIALIZER; 261 g_factory = LAZY_INSTANCE_INITIALIZER;
259 262
260 BrowserContextKeyedAPIFactory<OperationManager>* 263 BrowserContextKeyedAPIFactory<OperationManager>*
261 OperationManager::GetFactoryInstance() { 264 OperationManager::GetFactoryInstance() {
262 return g_factory.Pointer(); 265 return g_factory.Pointer();
263 } 266 }
264 267
265 268
266 } // namespace image_writer 269 } // namespace image_writer
267 } // namespace extensions 270 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/identity/web_auth_flow.cc ('k') | chrome/browser/extensions/api/input_ime/input_ime_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698