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

Side by Side Diff: content/browser/service_worker/service_worker_internals_ui.cc

Issue 985663002: Implement ServiceWorkerRegistration related DevTools events [2/2 chromium] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: override Created 5 years, 9 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 "content/browser/service_worker/service_worker_internals_ui.h" 5 #include "content/browser/service_worker/service_worker_internals_ui.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 297
298 } // namespace 298 } // namespace
299 299
300 class ServiceWorkerInternalsUI::PartitionObserver 300 class ServiceWorkerInternalsUI::PartitionObserver
301 : public ServiceWorkerContextObserver { 301 : public ServiceWorkerContextObserver {
302 public: 302 public:
303 PartitionObserver(int partition_id, WebUI* web_ui) 303 PartitionObserver(int partition_id, WebUI* web_ui)
304 : partition_id_(partition_id), web_ui_(web_ui) {} 304 : partition_id_(partition_id), web_ui_(web_ui) {}
305 ~PartitionObserver() override {} 305 ~PartitionObserver() override {}
306 // ServiceWorkerContextObserver overrides: 306 // ServiceWorkerContextObserver overrides:
307 void OnWorkerStarted(int64 version_id, 307 void OnRunningStateChanged(int64 version_id) override {
308 int process_id,
309 int thread_id) override {
310 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
311 web_ui_->CallJavascriptFunction( 309 web_ui_->CallJavascriptFunction(
312 "serviceworker.onWorkerStarted", 310 "serviceworker.onRunningStateChanged", FundamentalValue(partition_id_),
313 FundamentalValue(partition_id_), 311 StringValue(base::Int64ToString(version_id)));
314 StringValue(base::Int64ToString(version_id)),
315 FundamentalValue(process_id),
316 FundamentalValue(thread_id));
317 }
318 void OnWorkerStopped(int64 version_id,
319 int process_id,
320 int thread_id) override {
321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
322 web_ui_->CallJavascriptFunction(
323 "serviceworker.onWorkerStopped",
324 FundamentalValue(partition_id_),
325 StringValue(base::Int64ToString(version_id)),
326 FundamentalValue(process_id),
327 FundamentalValue(thread_id));
328 } 312 }
329 void OnVersionStateChanged(int64 version_id) override { 313 void OnVersionStateChanged(int64 version_id) override {
330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 314 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
331 web_ui_->CallJavascriptFunction( 315 web_ui_->CallJavascriptFunction(
332 "serviceworker.onVersionStateChanged", 316 "serviceworker.onVersionStateChanged",
333 FundamentalValue(partition_id_), 317 FundamentalValue(partition_id_),
334 StringValue(base::Int64ToString(version_id))); 318 StringValue(base::Int64ToString(version_id)));
335 } 319 }
336 void OnErrorReported(int64 version_id, 320 void OnErrorReported(int64 version_id,
337 int process_id, 321 int process_id,
(...skipping 27 matching lines...) Expand all
365 scoped_ptr<DictionaryValue> value(new DictionaryValue()); 349 scoped_ptr<DictionaryValue> value(new DictionaryValue());
366 value->SetInteger("sourceIdentifier", message.source_identifier); 350 value->SetInteger("sourceIdentifier", message.source_identifier);
367 value->SetInteger("message_level", message.message_level); 351 value->SetInteger("message_level", message.message_level);
368 value->SetString("message", message.message); 352 value->SetString("message", message.message);
369 value->SetInteger("lineNumber", message.line_number); 353 value->SetInteger("lineNumber", message.line_number);
370 value->SetString("sourceURL", message.source_url.spec()); 354 value->SetString("sourceURL", message.source_url.spec());
371 args.push_back(value.release()); 355 args.push_back(value.release());
372 web_ui_->CallJavascriptFunction("serviceworker.onConsoleMessageReported", 356 web_ui_->CallJavascriptFunction("serviceworker.onConsoleMessageReported",
373 args.get()); 357 args.get());
374 } 358 }
375 void OnRegistrationStored(const GURL& pattern) override { 359 void OnRegistrationStored(int64 registration_id,
360 const GURL& pattern) override {
376 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 361 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
377 web_ui_->CallJavascriptFunction("serviceworker.onRegistrationStored", 362 web_ui_->CallJavascriptFunction("serviceworker.onRegistrationStored",
378 StringValue(pattern.spec())); 363 StringValue(pattern.spec()));
379 } 364 }
380 void OnRegistrationDeleted(int64 registration_id, 365 void OnRegistrationDeleted(int64 registration_id,
381 const GURL& pattern) override { 366 const GURL& pattern) override {
382 web_ui_->CallJavascriptFunction("serviceworker.onRegistrationDeleted", 367 web_ui_->CallJavascriptFunction("serviceworker.onRegistrationDeleted",
383 StringValue(pattern.spec())); 368 StringValue(pattern.spec()));
384 } 369 }
385 int partition_id() const { return partition_id_; } 370 int partition_id() const { return partition_id_; }
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 return; 654 return;
670 } 655 }
671 656
672 base::Callback<void(ServiceWorkerStatusCode)> callback = 657 base::Callback<void(ServiceWorkerStatusCode)> callback =
673 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id); 658 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id);
674 FindRegistrationForPattern( 659 FindRegistrationForPattern(
675 context, GURL(scope_string), base::Bind(StartActiveWorker, callback)); 660 context, GURL(scope_string), base::Bind(StartActiveWorker, callback));
676 } 661 }
677 662
678 } // namespace content 663 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_info.cc ('k') | content/browser/service_worker/service_worker_version.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698