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

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

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 18 matching lines...) Expand all
29 #include "content/public/browser/render_process_host.h" 29 #include "content/public/browser/render_process_host.h"
30 #include "content/public/browser/storage_partition.h" 30 #include "content/public/browser/storage_partition.h"
31 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
32 #include "content/public/browser/web_ui.h" 32 #include "content/public/browser/web_ui.h"
33 #include "content/public/browser/web_ui_data_source.h" 33 #include "content/public/browser/web_ui_data_source.h"
34 #include "content/public/common/child_process_host.h" 34 #include "content/public/common/child_process_host.h"
35 #include "content/public/common/url_constants.h" 35 #include "content/public/common/url_constants.h"
36 36
37 using base::DictionaryValue; 37 using base::DictionaryValue;
38 using base::ListValue; 38 using base::ListValue;
39 using base::StringValue;
40 using base::Value; 39 using base::Value;
41 using base::WeakPtr; 40 using base::WeakPtr;
42 41
43 namespace content { 42 namespace content {
44 43
45 namespace { 44 namespace {
46 45
47 using GetRegistrationsCallback = 46 using GetRegistrationsCallback =
48 base::Callback<void(const std::vector<ServiceWorkerRegistrationInfo>&, 47 base::Callback<void(const std::vector<ServiceWorkerRegistrationInfo>&,
49 const std::vector<ServiceWorkerVersionInfo>&, 48 const std::vector<ServiceWorkerVersionInfo>&,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) { 254 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) {
256 DCHECK_CURRENTLY_ON(BrowserThread::UI); 255 DCHECK_CURRENTLY_ON(BrowserThread::UI);
257 if (!internals) 256 if (!internals)
258 return; 257 return;
259 258
260 std::vector<std::unique_ptr<const Value>> args; 259 std::vector<std::unique_ptr<const Value>> args;
261 args.push_back(GetRegistrationListValue(live_registrations)); 260 args.push_back(GetRegistrationListValue(live_registrations));
262 args.push_back(GetVersionListValue(live_versions)); 261 args.push_back(GetVersionListValue(live_versions));
263 args.push_back(GetRegistrationListValue(stored_registrations)); 262 args.push_back(GetRegistrationListValue(stored_registrations));
264 args.push_back(base::MakeUnique<Value>(partition_id)); 263 args.push_back(base::MakeUnique<Value>(partition_id));
265 args.push_back(base::MakeUnique<StringValue>(context_path.value())); 264 args.push_back(base::MakeUnique<Value>(context_path.value()));
266 internals->web_ui()->CallJavascriptFunctionUnsafe( 265 internals->web_ui()->CallJavascriptFunctionUnsafe(
267 "serviceworker.onPartitionData", ConvertToRawPtrVector(args)); 266 "serviceworker.onPartitionData", ConvertToRawPtrVector(args));
268 } 267 }
269 268
270 } // namespace 269 } // namespace
271 270
272 class ServiceWorkerInternalsUI::PartitionObserver 271 class ServiceWorkerInternalsUI::PartitionObserver
273 : public ServiceWorkerContextObserver { 272 : public ServiceWorkerContextObserver {
274 public: 273 public:
275 PartitionObserver(int partition_id, WebUI* web_ui) 274 PartitionObserver(int partition_id, WebUI* web_ui)
276 : partition_id_(partition_id), web_ui_(web_ui) {} 275 : partition_id_(partition_id), web_ui_(web_ui) {}
277 ~PartitionObserver() override {} 276 ~PartitionObserver() override {}
278 // ServiceWorkerContextObserver overrides: 277 // ServiceWorkerContextObserver overrides:
279 void OnRunningStateChanged(int64_t version_id, 278 void OnRunningStateChanged(int64_t version_id,
280 EmbeddedWorkerStatus) override { 279 EmbeddedWorkerStatus) override {
281 DCHECK_CURRENTLY_ON(BrowserThread::UI); 280 DCHECK_CURRENTLY_ON(BrowserThread::UI);
282 web_ui_->CallJavascriptFunctionUnsafe( 281 web_ui_->CallJavascriptFunctionUnsafe(
283 "serviceworker.onRunningStateChanged", Value(partition_id_), 282 "serviceworker.onRunningStateChanged", Value(partition_id_),
284 StringValue(base::Int64ToString(version_id))); 283 Value(base::Int64ToString(version_id)));
285 } 284 }
286 void OnVersionStateChanged(int64_t version_id, 285 void OnVersionStateChanged(int64_t version_id,
287 ServiceWorkerVersion::Status) override { 286 ServiceWorkerVersion::Status) override {
288 DCHECK_CURRENTLY_ON(BrowserThread::UI); 287 DCHECK_CURRENTLY_ON(BrowserThread::UI);
289 web_ui_->CallJavascriptFunctionUnsafe( 288 web_ui_->CallJavascriptFunctionUnsafe(
290 "serviceworker.onVersionStateChanged", Value(partition_id_), 289 "serviceworker.onVersionStateChanged", Value(partition_id_),
291 StringValue(base::Int64ToString(version_id))); 290 Value(base::Int64ToString(version_id)));
292 } 291 }
293 void OnErrorReported(int64_t version_id, 292 void OnErrorReported(int64_t version_id,
294 int process_id, 293 int process_id,
295 int thread_id, 294 int thread_id,
296 const ErrorInfo& info) override { 295 const ErrorInfo& info) override {
297 DCHECK_CURRENTLY_ON(BrowserThread::UI); 296 DCHECK_CURRENTLY_ON(BrowserThread::UI);
298 std::vector<std::unique_ptr<const Value>> args; 297 std::vector<std::unique_ptr<const Value>> args;
299 args.push_back(base::MakeUnique<Value>(partition_id_)); 298 args.push_back(base::MakeUnique<Value>(partition_id_));
300 args.push_back( 299 args.push_back(base::MakeUnique<Value>(base::Int64ToString(version_id)));
301 base::MakeUnique<StringValue>(base::Int64ToString(version_id)));
302 args.push_back(base::MakeUnique<Value>(process_id)); 300 args.push_back(base::MakeUnique<Value>(process_id));
303 args.push_back(base::MakeUnique<Value>(thread_id)); 301 args.push_back(base::MakeUnique<Value>(thread_id));
304 auto value = base::MakeUnique<DictionaryValue>(); 302 auto value = base::MakeUnique<DictionaryValue>();
305 value->SetString("message", info.error_message); 303 value->SetString("message", info.error_message);
306 value->SetInteger("lineNumber", info.line_number); 304 value->SetInteger("lineNumber", info.line_number);
307 value->SetInteger("columnNumber", info.column_number); 305 value->SetInteger("columnNumber", info.column_number);
308 value->SetString("sourceURL", info.source_url.spec()); 306 value->SetString("sourceURL", info.source_url.spec());
309 args.push_back(std::move(value)); 307 args.push_back(std::move(value));
310 web_ui_->CallJavascriptFunctionUnsafe("serviceworker.onErrorReported", 308 web_ui_->CallJavascriptFunctionUnsafe("serviceworker.onErrorReported",
311 ConvertToRawPtrVector(args)); 309 ConvertToRawPtrVector(args));
312 } 310 }
313 void OnReportConsoleMessage(int64_t version_id, 311 void OnReportConsoleMessage(int64_t version_id,
314 int process_id, 312 int process_id,
315 int thread_id, 313 int thread_id,
316 const ConsoleMessage& message) override { 314 const ConsoleMessage& message) override {
317 DCHECK_CURRENTLY_ON(BrowserThread::UI); 315 DCHECK_CURRENTLY_ON(BrowserThread::UI);
318 std::vector<std::unique_ptr<const Value>> args; 316 std::vector<std::unique_ptr<const Value>> args;
319 args.push_back(base::MakeUnique<Value>(partition_id_)); 317 args.push_back(base::MakeUnique<Value>(partition_id_));
320 args.push_back( 318 args.push_back(base::MakeUnique<Value>(base::Int64ToString(version_id)));
321 base::MakeUnique<StringValue>(base::Int64ToString(version_id)));
322 args.push_back(base::MakeUnique<Value>(process_id)); 319 args.push_back(base::MakeUnique<Value>(process_id));
323 args.push_back(base::MakeUnique<Value>(thread_id)); 320 args.push_back(base::MakeUnique<Value>(thread_id));
324 auto value = base::MakeUnique<DictionaryValue>(); 321 auto value = base::MakeUnique<DictionaryValue>();
325 value->SetInteger("sourceIdentifier", message.source_identifier); 322 value->SetInteger("sourceIdentifier", message.source_identifier);
326 value->SetInteger("message_level", message.message_level); 323 value->SetInteger("message_level", message.message_level);
327 value->SetString("message", message.message); 324 value->SetString("message", message.message);
328 value->SetInteger("lineNumber", message.line_number); 325 value->SetInteger("lineNumber", message.line_number);
329 value->SetString("sourceURL", message.source_url.spec()); 326 value->SetString("sourceURL", message.source_url.spec());
330 args.push_back(std::move(value)); 327 args.push_back(std::move(value));
331 web_ui_->CallJavascriptFunctionUnsafe( 328 web_ui_->CallJavascriptFunctionUnsafe(
332 "serviceworker.onConsoleMessageReported", ConvertToRawPtrVector(args)); 329 "serviceworker.onConsoleMessageReported", ConvertToRawPtrVector(args));
333 } 330 }
334 void OnRegistrationStored(int64_t registration_id, 331 void OnRegistrationStored(int64_t registration_id,
335 const GURL& pattern) override { 332 const GURL& pattern) override {
336 DCHECK_CURRENTLY_ON(BrowserThread::UI); 333 DCHECK_CURRENTLY_ON(BrowserThread::UI);
337 web_ui_->CallJavascriptFunctionUnsafe("serviceworker.onRegistrationStored", 334 web_ui_->CallJavascriptFunctionUnsafe("serviceworker.onRegistrationStored",
338 StringValue(pattern.spec())); 335 Value(pattern.spec()));
339 } 336 }
340 void OnRegistrationDeleted(int64_t registration_id, 337 void OnRegistrationDeleted(int64_t registration_id,
341 const GURL& pattern) override { 338 const GURL& pattern) override {
342 web_ui_->CallJavascriptFunctionUnsafe("serviceworker.onRegistrationDeleted", 339 web_ui_->CallJavascriptFunctionUnsafe("serviceworker.onRegistrationDeleted",
343 StringValue(pattern.spec())); 340 Value(pattern.spec()));
344 } 341 }
345 int partition_id() const { return partition_id_; } 342 int partition_id() const { return partition_id_; }
346 343
347 private: 344 private:
348 const int partition_id_; 345 const int partition_id_;
349 WebUI* const web_ui_; 346 WebUI* const web_ui_;
350 }; 347 };
351 348
352 ServiceWorkerInternalsUI::ServiceWorkerInternalsUI(WebUI* web_ui) 349 ServiceWorkerInternalsUI::ServiceWorkerInternalsUI(WebUI* web_ui)
353 : WebUIController(web_ui), next_partition_id_(0) { 350 : WebUIController(web_ui), next_partition_id_(0) {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 callback.Run(SERVICE_WORKER_ERROR_ABORT); 610 callback.Run(SERVICE_WORKER_ERROR_ABORT);
614 return; 611 return;
615 } 612 }
616 613
617 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here 614 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here
618 // because that reduces a status code to boolean. 615 // because that reduces a status code to boolean.
619 context->context()->UnregisterServiceWorker(scope, callback); 616 context->context()->UnregisterServiceWorker(scope, callback);
620 } 617 }
621 618
622 } // namespace content 619 } // 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