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

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

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 years, 1 month 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 15 matching lines...) Expand all
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/render_process_host.h" 27 #include "content/public/browser/render_process_host.h"
28 #include "content/public/browser/storage_partition.h" 28 #include "content/public/browser/storage_partition.h"
29 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
30 #include "content/public/browser/web_ui.h" 30 #include "content/public/browser/web_ui.h"
31 #include "content/public/browser/web_ui_data_source.h" 31 #include "content/public/browser/web_ui_data_source.h"
32 #include "content/public/common/child_process_host.h" 32 #include "content/public/common/child_process_host.h"
33 #include "content/public/common/url_constants.h" 33 #include "content/public/common/url_constants.h"
34 34
35 using base::DictionaryValue; 35 using base::DictionaryValue;
36 using base::FundamentalValue; 36 using base::Value;
37 using base::ListValue; 37 using base::ListValue;
38 using base::StringValue; 38 using base::StringValue;
39 using base::Value; 39 using base::Value;
40 using base::WeakPtr; 40 using base::WeakPtr;
41 41
42 namespace content { 42 namespace content {
43 43
44 namespace { 44 namespace {
45 45
46 using GetRegistrationsCallback = 46 using GetRegistrationsCallback =
47 base::Callback<void(const std::vector<ServiceWorkerRegistrationInfo>&, 47 base::Callback<void(const std::vector<ServiceWorkerRegistrationInfo>&,
48 const std::vector<ServiceWorkerVersionInfo>&, 48 const std::vector<ServiceWorkerVersionInfo>&,
49 const std::vector<ServiceWorkerRegistrationInfo>&)>; 49 const std::vector<ServiceWorkerRegistrationInfo>&)>;
50 50
51 void OperationCompleteCallback(WeakPtr<ServiceWorkerInternalsUI> internals, 51 void OperationCompleteCallback(WeakPtr<ServiceWorkerInternalsUI> internals,
52 int callback_id, 52 int callback_id,
53 ServiceWorkerStatusCode status) { 53 ServiceWorkerStatusCode status) {
54 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 54 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
55 BrowserThread::PostTask( 55 BrowserThread::PostTask(
56 BrowserThread::UI, 56 BrowserThread::UI,
57 FROM_HERE, 57 FROM_HERE,
58 base::Bind(OperationCompleteCallback, internals, callback_id, status)); 58 base::Bind(OperationCompleteCallback, internals, callback_id, status));
59 return; 59 return;
60 } 60 }
61 DCHECK_CURRENTLY_ON(BrowserThread::UI); 61 DCHECK_CURRENTLY_ON(BrowserThread::UI);
62 if (internals) { 62 if (internals) {
63 internals->web_ui()->CallJavascriptFunctionUnsafe( 63 internals->web_ui()->CallJavascriptFunctionUnsafe(
64 "serviceworker.onOperationComplete", 64 "serviceworker.onOperationComplete", Value(static_cast<int>(status)),
65 FundamentalValue(static_cast<int>(status)), 65 Value(callback_id));
66 FundamentalValue(callback_id));
67 } 66 }
68 } 67 }
69 68
70 void CallServiceWorkerVersionMethodWithVersionID( 69 void CallServiceWorkerVersionMethodWithVersionID(
71 ServiceWorkerInternalsUI::ServiceWorkerVersionMethod method, 70 ServiceWorkerInternalsUI::ServiceWorkerVersionMethod method,
72 scoped_refptr<ServiceWorkerContextWrapper> context, 71 scoped_refptr<ServiceWorkerContextWrapper> context,
73 int64_t version_id, 72 int64_t version_id,
74 const ServiceWorkerInternalsUI::StatusCallback& callback) { 73 const ServiceWorkerInternalsUI::StatusCallback& callback) {
75 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 74 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
76 BrowserThread::PostTask( 75 BrowserThread::PostTask(
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 const std::vector<ServiceWorkerVersionInfo>& live_versions, 244 const std::vector<ServiceWorkerVersionInfo>& live_versions,
246 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) { 245 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) {
247 DCHECK_CURRENTLY_ON(BrowserThread::UI); 246 DCHECK_CURRENTLY_ON(BrowserThread::UI);
248 if (!internals) 247 if (!internals)
249 return; 248 return;
250 249
251 ScopedVector<const Value> args; 250 ScopedVector<const Value> args;
252 args.push_back(GetRegistrationListValue(live_registrations)); 251 args.push_back(GetRegistrationListValue(live_registrations));
253 args.push_back(GetVersionListValue(live_versions)); 252 args.push_back(GetVersionListValue(live_versions));
254 args.push_back(GetRegistrationListValue(stored_registrations)); 253 args.push_back(GetRegistrationListValue(stored_registrations));
255 args.push_back(new FundamentalValue(partition_id)); 254 args.push_back(new Value(partition_id));
256 args.push_back(new StringValue(context_path.value())); 255 args.push_back(new StringValue(context_path.value()));
257 internals->web_ui()->CallJavascriptFunctionUnsafe( 256 internals->web_ui()->CallJavascriptFunctionUnsafe(
258 "serviceworker.onPartitionData", args.get()); 257 "serviceworker.onPartitionData", args.get());
259 } 258 }
260 259
261 } // namespace 260 } // namespace
262 261
263 class ServiceWorkerInternalsUI::PartitionObserver 262 class ServiceWorkerInternalsUI::PartitionObserver
264 : public ServiceWorkerContextObserver { 263 : public ServiceWorkerContextObserver {
265 public: 264 public:
266 PartitionObserver(int partition_id, WebUI* web_ui) 265 PartitionObserver(int partition_id, WebUI* web_ui)
267 : partition_id_(partition_id), web_ui_(web_ui) {} 266 : partition_id_(partition_id), web_ui_(web_ui) {}
268 ~PartitionObserver() override {} 267 ~PartitionObserver() override {}
269 // ServiceWorkerContextObserver overrides: 268 // ServiceWorkerContextObserver overrides:
270 void OnRunningStateChanged(int64_t version_id, 269 void OnRunningStateChanged(int64_t version_id,
271 EmbeddedWorkerStatus) override { 270 EmbeddedWorkerStatus) override {
272 DCHECK_CURRENTLY_ON(BrowserThread::UI); 271 DCHECK_CURRENTLY_ON(BrowserThread::UI);
273 web_ui_->CallJavascriptFunctionUnsafe( 272 web_ui_->CallJavascriptFunctionUnsafe(
274 "serviceworker.onRunningStateChanged", FundamentalValue(partition_id_), 273 "serviceworker.onRunningStateChanged", Value(partition_id_),
275 StringValue(base::Int64ToString(version_id))); 274 StringValue(base::Int64ToString(version_id)));
276 } 275 }
277 void OnVersionStateChanged(int64_t version_id, 276 void OnVersionStateChanged(int64_t version_id,
278 ServiceWorkerVersion::Status) override { 277 ServiceWorkerVersion::Status) override {
279 DCHECK_CURRENTLY_ON(BrowserThread::UI); 278 DCHECK_CURRENTLY_ON(BrowserThread::UI);
280 web_ui_->CallJavascriptFunctionUnsafe( 279 web_ui_->CallJavascriptFunctionUnsafe(
281 "serviceworker.onVersionStateChanged", FundamentalValue(partition_id_), 280 "serviceworker.onVersionStateChanged", Value(partition_id_),
282 StringValue(base::Int64ToString(version_id))); 281 StringValue(base::Int64ToString(version_id)));
283 } 282 }
284 void OnErrorReported(int64_t version_id, 283 void OnErrorReported(int64_t version_id,
285 int process_id, 284 int process_id,
286 int thread_id, 285 int thread_id,
287 const ErrorInfo& info) override { 286 const ErrorInfo& info) override {
288 DCHECK_CURRENTLY_ON(BrowserThread::UI); 287 DCHECK_CURRENTLY_ON(BrowserThread::UI);
289 ScopedVector<const Value> args; 288 ScopedVector<const Value> args;
290 args.push_back(new FundamentalValue(partition_id_)); 289 args.push_back(new Value(partition_id_));
291 args.push_back(new StringValue(base::Int64ToString(version_id))); 290 args.push_back(new StringValue(base::Int64ToString(version_id)));
292 args.push_back(new FundamentalValue(process_id)); 291 args.push_back(new Value(process_id));
293 args.push_back(new FundamentalValue(thread_id)); 292 args.push_back(new Value(thread_id));
294 std::unique_ptr<DictionaryValue> value(new DictionaryValue()); 293 std::unique_ptr<DictionaryValue> value(new DictionaryValue());
295 value->SetString("message", info.error_message); 294 value->SetString("message", info.error_message);
296 value->SetInteger("lineNumber", info.line_number); 295 value->SetInteger("lineNumber", info.line_number);
297 value->SetInteger("columnNumber", info.column_number); 296 value->SetInteger("columnNumber", info.column_number);
298 value->SetString("sourceURL", info.source_url.spec()); 297 value->SetString("sourceURL", info.source_url.spec());
299 args.push_back(value.release()); 298 args.push_back(value.release());
300 web_ui_->CallJavascriptFunctionUnsafe("serviceworker.onErrorReported", 299 web_ui_->CallJavascriptFunctionUnsafe("serviceworker.onErrorReported",
301 args.get()); 300 args.get());
302 } 301 }
303 void OnReportConsoleMessage(int64_t version_id, 302 void OnReportConsoleMessage(int64_t version_id,
304 int process_id, 303 int process_id,
305 int thread_id, 304 int thread_id,
306 const ConsoleMessage& message) override { 305 const ConsoleMessage& message) override {
307 DCHECK_CURRENTLY_ON(BrowserThread::UI); 306 DCHECK_CURRENTLY_ON(BrowserThread::UI);
308 ScopedVector<const Value> args; 307 ScopedVector<const Value> args;
309 args.push_back(new FundamentalValue(partition_id_)); 308 args.push_back(new Value(partition_id_));
310 args.push_back(new StringValue(base::Int64ToString(version_id))); 309 args.push_back(new StringValue(base::Int64ToString(version_id)));
311 args.push_back(new FundamentalValue(process_id)); 310 args.push_back(new Value(process_id));
312 args.push_back(new FundamentalValue(thread_id)); 311 args.push_back(new Value(thread_id));
313 std::unique_ptr<DictionaryValue> value(new DictionaryValue()); 312 std::unique_ptr<DictionaryValue> value(new DictionaryValue());
314 value->SetInteger("sourceIdentifier", message.source_identifier); 313 value->SetInteger("sourceIdentifier", message.source_identifier);
315 value->SetInteger("message_level", message.message_level); 314 value->SetInteger("message_level", message.message_level);
316 value->SetString("message", message.message); 315 value->SetString("message", message.message);
317 value->SetInteger("lineNumber", message.line_number); 316 value->SetInteger("lineNumber", message.line_number);
318 value->SetString("sourceURL", message.source_url.spec()); 317 value->SetString("sourceURL", message.source_url.spec());
319 args.push_back(value.release()); 318 args.push_back(value.release());
320 web_ui_->CallJavascriptFunctionUnsafe( 319 web_ui_->CallJavascriptFunctionUnsafe(
321 "serviceworker.onConsoleMessageReported", args.get()); 320 "serviceworker.onConsoleMessageReported", args.get());
322 } 321 }
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 callback.Run(SERVICE_WORKER_ERROR_ABORT); 601 callback.Run(SERVICE_WORKER_ERROR_ABORT);
603 return; 602 return;
604 } 603 }
605 604
606 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here 605 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here
607 // because that reduces a status code to boolean. 606 // because that reduces a status code to boolean.
608 context->context()->UnregisterServiceWorker(scope, callback); 607 context->context()->UnregisterServiceWorker(scope, callback);
609 } 608 }
610 609
611 } // namespace content 610 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/pepper/pepper_socket_utils.cc ('k') | content/browser/tracing/etw_tracing_agent_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698