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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 scoped_ptr<DictionaryValue> value(new DictionaryValue()); | 150 scoped_ptr<DictionaryValue> value(new DictionaryValue()); |
151 value->SetInteger("sourceIdentifier", message.source_identifier); | 151 value->SetInteger("sourceIdentifier", message.source_identifier); |
152 value->SetInteger("message_level", message.message_level); | 152 value->SetInteger("message_level", message.message_level); |
153 value->SetString("message", message.message); | 153 value->SetString("message", message.message); |
154 value->SetInteger("lineNumber", message.line_number); | 154 value->SetInteger("lineNumber", message.line_number); |
155 value->SetString("sourceURL", message.source_url.spec()); | 155 value->SetString("sourceURL", message.source_url.spec()); |
156 args.push_back(value.release()); | 156 args.push_back(value.release()); |
157 web_ui_->CallJavascriptFunction("serviceworker.onConsoleMessageReported", | 157 web_ui_->CallJavascriptFunction("serviceworker.onConsoleMessageReported", |
158 args.get()); | 158 args.get()); |
159 } | 159 } |
| 160 virtual void OnRegistrationStored(const GURL& pattern) OVERRIDE { |
| 161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 162 web_ui_->CallJavascriptFunction("serviceworker.onRegistrationStored", |
| 163 StringValue(pattern.spec())); |
| 164 } |
| 165 virtual void OnRegistrationDeleted(const GURL& pattern) OVERRIDE { |
| 166 web_ui_->CallJavascriptFunction("serviceworker.onRegistrationDeleted", |
| 167 StringValue(pattern.spec())); |
| 168 } |
160 int partition_id() const { return partition_id_; } | 169 int partition_id() const { return partition_id_; } |
161 | 170 |
162 private: | 171 private: |
163 const int partition_id_; | 172 const int partition_id_; |
164 WebUI* const web_ui_; | 173 WebUI* const web_ui_; |
165 }; | 174 }; |
166 | 175 |
167 ServiceWorkerInternalsUI::ServiceWorkerInternalsUI(WebUI* web_ui) | 176 ServiceWorkerInternalsUI::ServiceWorkerInternalsUI(WebUI* web_ui) |
168 : WebUIController(web_ui), next_partition_id_(0) { | 177 : WebUIController(web_ui), next_partition_id_(0) { |
169 WebUIDataSource* source = | 178 WebUIDataSource* source = |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 | 533 |
525 if (!registration.pending_version.is_null) { | 534 if (!registration.pending_version.is_null) { |
526 DictionaryValue* pending_info = new DictionaryValue(); | 535 DictionaryValue* pending_info = new DictionaryValue(); |
527 UpdateVersionInfo(registration.pending_version, pending_info); | 536 UpdateVersionInfo(registration.pending_version, pending_info); |
528 registration_info->Set("pending", pending_info); | 537 registration_info->Set("pending", pending_info); |
529 } | 538 } |
530 | 539 |
531 result.Append(registration_info); | 540 result.Append(registration_info); |
532 } | 541 } |
533 | 542 |
534 if (internals_ && !result.empty()) | 543 if (internals_) |
535 internals_->web_ui()->CallJavascriptFunction( | 544 internals_->web_ui()->CallJavascriptFunction( |
536 "serviceworker.onPartitionData", | 545 "serviceworker.onPartitionData", |
537 result, | 546 result, |
538 FundamentalValue(partition_id), | 547 FundamentalValue(partition_id), |
539 StringValue(context_path.value())); | 548 StringValue(context_path.value())); |
540 } | 549 } |
541 | 550 |
542 void ServiceWorkerInternalsUI::OperationProxy::OperationComplete( | 551 void ServiceWorkerInternalsUI::OperationProxy::OperationComplete( |
543 ServiceWorkerStatusCode status) { | 552 ServiceWorkerStatusCode status) { |
544 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 553 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 ServiceWorkerVersion::ACTIVE) { | 604 ServiceWorkerVersion::ACTIVE) { |
596 registration->active_version()->DispatchSyncEvent(base::Bind( | 605 registration->active_version()->DispatchSyncEvent(base::Bind( |
597 &ServiceWorkerInternalsUI::OperationProxy::OperationComplete, this)); | 606 &ServiceWorkerInternalsUI::OperationProxy::OperationComplete, this)); |
598 return; | 607 return; |
599 } | 608 } |
600 | 609 |
601 OperationComplete(SERVICE_WORKER_ERROR_FAILED); | 610 OperationComplete(SERVICE_WORKER_ERROR_FAILED); |
602 } | 611 } |
603 | 612 |
604 } // namespace content | 613 } // namespace content |
OLD | NEW |