OLD | NEW |
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 Loading... |
297 | 297 |
298 class ServiceWorkerInternalsUI::PartitionObserver | 298 class ServiceWorkerInternalsUI::PartitionObserver |
299 : public ServiceWorkerContextObserver { | 299 : public ServiceWorkerContextObserver { |
300 public: | 300 public: |
301 PartitionObserver(int partition_id, WebUI* web_ui) | 301 PartitionObserver(int partition_id, WebUI* web_ui) |
302 : partition_id_(partition_id), web_ui_(web_ui) {} | 302 : partition_id_(partition_id), web_ui_(web_ui) {} |
303 virtual ~PartitionObserver() {} | 303 virtual ~PartitionObserver() {} |
304 // ServiceWorkerContextObserver overrides: | 304 // ServiceWorkerContextObserver overrides: |
305 virtual void OnWorkerStarted(int64 version_id, | 305 virtual void OnWorkerStarted(int64 version_id, |
306 int process_id, | 306 int process_id, |
307 int thread_id) OVERRIDE { | 307 int thread_id) override { |
308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
309 web_ui_->CallJavascriptFunction( | 309 web_ui_->CallJavascriptFunction( |
310 "serviceworker.onWorkerStarted", | 310 "serviceworker.onWorkerStarted", |
311 FundamentalValue(partition_id_), | 311 FundamentalValue(partition_id_), |
312 StringValue(base::Int64ToString(version_id)), | 312 StringValue(base::Int64ToString(version_id)), |
313 FundamentalValue(process_id), | 313 FundamentalValue(process_id), |
314 FundamentalValue(thread_id)); | 314 FundamentalValue(thread_id)); |
315 } | 315 } |
316 virtual void OnWorkerStopped(int64 version_id, | 316 virtual void OnWorkerStopped(int64 version_id, |
317 int process_id, | 317 int process_id, |
318 int thread_id) OVERRIDE { | 318 int thread_id) override { |
319 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 319 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
320 web_ui_->CallJavascriptFunction( | 320 web_ui_->CallJavascriptFunction( |
321 "serviceworker.onWorkerStopped", | 321 "serviceworker.onWorkerStopped", |
322 FundamentalValue(partition_id_), | 322 FundamentalValue(partition_id_), |
323 StringValue(base::Int64ToString(version_id)), | 323 StringValue(base::Int64ToString(version_id)), |
324 FundamentalValue(process_id), | 324 FundamentalValue(process_id), |
325 FundamentalValue(thread_id)); | 325 FundamentalValue(thread_id)); |
326 } | 326 } |
327 virtual void OnVersionStateChanged(int64 version_id) OVERRIDE { | 327 virtual void OnVersionStateChanged(int64 version_id) override { |
328 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 328 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
329 web_ui_->CallJavascriptFunction( | 329 web_ui_->CallJavascriptFunction( |
330 "serviceworker.onVersionStateChanged", | 330 "serviceworker.onVersionStateChanged", |
331 FundamentalValue(partition_id_), | 331 FundamentalValue(partition_id_), |
332 StringValue(base::Int64ToString(version_id))); | 332 StringValue(base::Int64ToString(version_id))); |
333 } | 333 } |
334 virtual void OnErrorReported(int64 version_id, | 334 virtual void OnErrorReported(int64 version_id, |
335 int process_id, | 335 int process_id, |
336 int thread_id, | 336 int thread_id, |
337 const ErrorInfo& info) OVERRIDE { | 337 const ErrorInfo& info) override { |
338 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 338 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
339 ScopedVector<const Value> args; | 339 ScopedVector<const Value> args; |
340 args.push_back(new FundamentalValue(partition_id_)); | 340 args.push_back(new FundamentalValue(partition_id_)); |
341 args.push_back(new StringValue(base::Int64ToString(version_id))); | 341 args.push_back(new StringValue(base::Int64ToString(version_id))); |
342 args.push_back(new FundamentalValue(process_id)); | 342 args.push_back(new FundamentalValue(process_id)); |
343 args.push_back(new FundamentalValue(thread_id)); | 343 args.push_back(new FundamentalValue(thread_id)); |
344 scoped_ptr<DictionaryValue> value(new DictionaryValue()); | 344 scoped_ptr<DictionaryValue> value(new DictionaryValue()); |
345 value->SetString("message", info.error_message); | 345 value->SetString("message", info.error_message); |
346 value->SetInteger("lineNumber", info.line_number); | 346 value->SetInteger("lineNumber", info.line_number); |
347 value->SetInteger("columnNumber", info.column_number); | 347 value->SetInteger("columnNumber", info.column_number); |
348 value->SetString("sourceURL", info.source_url.spec()); | 348 value->SetString("sourceURL", info.source_url.spec()); |
349 args.push_back(value.release()); | 349 args.push_back(value.release()); |
350 web_ui_->CallJavascriptFunction("serviceworker.onErrorReported", | 350 web_ui_->CallJavascriptFunction("serviceworker.onErrorReported", |
351 args.get()); | 351 args.get()); |
352 } | 352 } |
353 virtual void OnReportConsoleMessage(int64 version_id, | 353 virtual void OnReportConsoleMessage(int64 version_id, |
354 int process_id, | 354 int process_id, |
355 int thread_id, | 355 int thread_id, |
356 const ConsoleMessage& message) OVERRIDE { | 356 const ConsoleMessage& message) override { |
357 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 357 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
358 ScopedVector<const Value> args; | 358 ScopedVector<const Value> args; |
359 args.push_back(new FundamentalValue(partition_id_)); | 359 args.push_back(new FundamentalValue(partition_id_)); |
360 args.push_back(new StringValue(base::Int64ToString(version_id))); | 360 args.push_back(new StringValue(base::Int64ToString(version_id))); |
361 args.push_back(new FundamentalValue(process_id)); | 361 args.push_back(new FundamentalValue(process_id)); |
362 args.push_back(new FundamentalValue(thread_id)); | 362 args.push_back(new FundamentalValue(thread_id)); |
363 scoped_ptr<DictionaryValue> value(new DictionaryValue()); | 363 scoped_ptr<DictionaryValue> value(new DictionaryValue()); |
364 value->SetInteger("sourceIdentifier", message.source_identifier); | 364 value->SetInteger("sourceIdentifier", message.source_identifier); |
365 value->SetInteger("message_level", message.message_level); | 365 value->SetInteger("message_level", message.message_level); |
366 value->SetString("message", message.message); | 366 value->SetString("message", message.message); |
367 value->SetInteger("lineNumber", message.line_number); | 367 value->SetInteger("lineNumber", message.line_number); |
368 value->SetString("sourceURL", message.source_url.spec()); | 368 value->SetString("sourceURL", message.source_url.spec()); |
369 args.push_back(value.release()); | 369 args.push_back(value.release()); |
370 web_ui_->CallJavascriptFunction("serviceworker.onConsoleMessageReported", | 370 web_ui_->CallJavascriptFunction("serviceworker.onConsoleMessageReported", |
371 args.get()); | 371 args.get()); |
372 } | 372 } |
373 virtual void OnRegistrationStored(const GURL& pattern) OVERRIDE { | 373 virtual void OnRegistrationStored(const GURL& pattern) override { |
374 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 374 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
375 web_ui_->CallJavascriptFunction("serviceworker.onRegistrationStored", | 375 web_ui_->CallJavascriptFunction("serviceworker.onRegistrationStored", |
376 StringValue(pattern.spec())); | 376 StringValue(pattern.spec())); |
377 } | 377 } |
378 virtual void OnRegistrationDeleted(const GURL& pattern) OVERRIDE { | 378 virtual void OnRegistrationDeleted(const GURL& pattern) override { |
379 web_ui_->CallJavascriptFunction("serviceworker.onRegistrationDeleted", | 379 web_ui_->CallJavascriptFunction("serviceworker.onRegistrationDeleted", |
380 StringValue(pattern.spec())); | 380 StringValue(pattern.spec())); |
381 } | 381 } |
382 int partition_id() const { return partition_id_; } | 382 int partition_id() const { return partition_id_; } |
383 | 383 |
384 private: | 384 private: |
385 const int partition_id_; | 385 const int partition_id_; |
386 WebUI* const web_ui_; | 386 WebUI* const web_ui_; |
387 }; | 387 }; |
388 | 388 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 return; | 666 return; |
667 } | 667 } |
668 | 668 |
669 base::Callback<void(ServiceWorkerStatusCode)> callback = | 669 base::Callback<void(ServiceWorkerStatusCode)> callback = |
670 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id); | 670 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id); |
671 FindRegistrationForPattern( | 671 FindRegistrationForPattern( |
672 context, GURL(scope_string), base::Bind(StartActiveWorker, callback)); | 672 context, GURL(scope_string), base::Bind(StartActiveWorker, callback)); |
673 } | 673 } |
674 | 674 |
675 } // namespace content | 675 } // namespace content |
OLD | NEW |