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

Side by Side Diff: content/renderer/service_worker/service_worker_context_client.cc

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Rebase on some ScreenOrientation changes, update that stuff to use unique_ptr (the change I was sca… Created 4 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/renderer/service_worker/service_worker_context_client.h" 5 #include "content/renderer/service_worker/service_worker_context_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 service_manager::InterfaceProviderSpec()); 463 service_manager::InterfaceProviderSpec());
464 context_->remote_interfaces.Bind(std::move(remote_interfaces)); 464 context_->remote_interfaces.Bind(std::move(remote_interfaces));
465 } 465 }
466 466
467 blink::WebURL ServiceWorkerContextClient::scope() const { 467 blink::WebURL ServiceWorkerContextClient::scope() const {
468 return service_worker_scope_; 468 return service_worker_scope_;
469 } 469 }
470 470
471 void ServiceWorkerContextClient::getClient( 471 void ServiceWorkerContextClient::getClient(
472 const blink::WebString& id, 472 const blink::WebString& id,
473 blink::WebServiceWorkerClientCallbacks* callbacks) { 473 std::unique_ptr<blink::WebServiceWorkerClientCallbacks> callbacks) {
474 DCHECK(callbacks); 474 DCHECK(callbacks);
475 int request_id = context_->client_callbacks.Add(callbacks); 475 int request_id = context_->client_callbacks.Add(std::move(callbacks));
476 Send(new ServiceWorkerHostMsg_GetClient( 476 Send(new ServiceWorkerHostMsg_GetClient(
477 GetRoutingID(), request_id, base::UTF16ToUTF8(base::StringPiece16(id)))); 477 GetRoutingID(), request_id, base::UTF16ToUTF8(base::StringPiece16(id))));
478 } 478 }
479 479
480 void ServiceWorkerContextClient::getClients( 480 void ServiceWorkerContextClient::getClients(
481 const blink::WebServiceWorkerClientQueryOptions& weboptions, 481 const blink::WebServiceWorkerClientQueryOptions& weboptions,
482 blink::WebServiceWorkerClientsCallbacks* callbacks) { 482 std::unique_ptr<blink::WebServiceWorkerClientsCallbacks> callbacks) {
483 DCHECK(callbacks); 483 DCHECK(callbacks);
484 int request_id = context_->clients_callbacks.Add(callbacks); 484 int request_id = context_->clients_callbacks.Add(std::move(callbacks));
485 ServiceWorkerClientQueryOptions options; 485 ServiceWorkerClientQueryOptions options;
486 options.client_type = weboptions.clientType; 486 options.client_type = weboptions.clientType;
487 options.include_uncontrolled = weboptions.includeUncontrolled; 487 options.include_uncontrolled = weboptions.includeUncontrolled;
488 Send(new ServiceWorkerHostMsg_GetClients( 488 Send(new ServiceWorkerHostMsg_GetClients(
489 GetRoutingID(), request_id, options)); 489 GetRoutingID(), request_id, options));
490 } 490 }
491 491
492 void ServiceWorkerContextClient::openWindow( 492 void ServiceWorkerContextClient::openWindow(
493 const blink::WebURL& url, 493 const blink::WebURL& url,
494 blink::WebServiceWorkerClientCallbacks* callbacks) { 494 std::unique_ptr<blink::WebServiceWorkerClientCallbacks> callbacks) {
495 DCHECK(callbacks); 495 DCHECK(callbacks);
496 int request_id = context_->client_callbacks.Add(callbacks); 496 int request_id = context_->client_callbacks.Add(std::move(callbacks));
497 Send(new ServiceWorkerHostMsg_OpenWindow( 497 Send(new ServiceWorkerHostMsg_OpenWindow(
498 GetRoutingID(), request_id, url)); 498 GetRoutingID(), request_id, url));
499 } 499 }
500 500
501 void ServiceWorkerContextClient::setCachedMetadata(const blink::WebURL& url, 501 void ServiceWorkerContextClient::setCachedMetadata(const blink::WebURL& url,
502 const char* data, 502 const char* data,
503 size_t size) { 503 size_t size) {
504 std::vector<char> copy(data, data + size); 504 std::vector<char> copy(data, data + size);
505 Send(new ServiceWorkerHostMsg_SetCachedMetadata(GetRoutingID(), url, copy)); 505 Send(new ServiceWorkerHostMsg_SetCachedMetadata(GetRoutingID(), url, copy));
506 } 506 }
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 883
884 void ServiceWorkerContextClient::postMessageToCrossOriginClient( 884 void ServiceWorkerContextClient::postMessageToCrossOriginClient(
885 const blink::WebCrossOriginServiceWorkerClient&, 885 const blink::WebCrossOriginServiceWorkerClient&,
886 const blink::WebString&, 886 const blink::WebString&,
887 blink::WebMessagePortChannelArray*) { 887 blink::WebMessagePortChannelArray*) {
888 NOTREACHED(); 888 NOTREACHED();
889 } 889 }
890 890
891 void ServiceWorkerContextClient::focus( 891 void ServiceWorkerContextClient::focus(
892 const blink::WebString& uuid, 892 const blink::WebString& uuid,
893 blink::WebServiceWorkerClientCallbacks* callback) { 893 std::unique_ptr<blink::WebServiceWorkerClientCallbacks> callback) {
894 DCHECK(callback); 894 DCHECK(callback);
895 int request_id = context_->client_callbacks.Add(callback); 895 int request_id = context_->client_callbacks.Add(std::move(callback));
896 Send(new ServiceWorkerHostMsg_FocusClient( 896 Send(new ServiceWorkerHostMsg_FocusClient(
897 GetRoutingID(), request_id, 897 GetRoutingID(), request_id,
898 base::UTF16ToUTF8(base::StringPiece16(uuid)))); 898 base::UTF16ToUTF8(base::StringPiece16(uuid))));
899 } 899 }
900 900
901 void ServiceWorkerContextClient::navigate( 901 void ServiceWorkerContextClient::navigate(
902 const blink::WebString& uuid, 902 const blink::WebString& uuid,
903 const blink::WebURL& url, 903 const blink::WebURL& url,
904 blink::WebServiceWorkerClientCallbacks* callback) { 904 std::unique_ptr<blink::WebServiceWorkerClientCallbacks> callback) {
905 DCHECK(callback); 905 DCHECK(callback);
906 int request_id = context_->client_callbacks.Add(callback); 906 int request_id = context_->client_callbacks.Add(std::move(callback));
907 Send(new ServiceWorkerHostMsg_NavigateClient( 907 Send(new ServiceWorkerHostMsg_NavigateClient(
908 GetRoutingID(), request_id, base::UTF16ToUTF8(base::StringPiece16(uuid)), 908 GetRoutingID(), request_id, base::UTF16ToUTF8(base::StringPiece16(uuid)),
909 url)); 909 url));
910 } 910 }
911 911
912 void ServiceWorkerContextClient::skipWaiting( 912 void ServiceWorkerContextClient::skipWaiting(
913 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks) { 913 std::unique_ptr<blink::WebServiceWorkerSkipWaitingCallbacks> callbacks) {
914 DCHECK(callbacks); 914 DCHECK(callbacks);
915 int request_id = context_->skip_waiting_callbacks.Add(callbacks); 915 int request_id = context_->skip_waiting_callbacks.Add(std::move(callbacks));
916 Send(new ServiceWorkerHostMsg_SkipWaiting(GetRoutingID(), request_id)); 916 Send(new ServiceWorkerHostMsg_SkipWaiting(GetRoutingID(), request_id));
917 } 917 }
918 918
919 void ServiceWorkerContextClient::claim( 919 void ServiceWorkerContextClient::claim(
920 blink::WebServiceWorkerClientsClaimCallbacks* callbacks) { 920 std::unique_ptr<blink::WebServiceWorkerClientsClaimCallbacks> callbacks) {
921 DCHECK(callbacks); 921 DCHECK(callbacks);
922 int request_id = context_->claim_clients_callbacks.Add(callbacks); 922 int request_id = context_->claim_clients_callbacks.Add(std::move(callbacks));
923 Send(new ServiceWorkerHostMsg_ClaimClients(GetRoutingID(), request_id)); 923 Send(new ServiceWorkerHostMsg_ClaimClients(GetRoutingID(), request_id));
924 } 924 }
925 925
926 void ServiceWorkerContextClient::registerForeignFetchScopes( 926 void ServiceWorkerContextClient::registerForeignFetchScopes(
927 const blink::WebVector<blink::WebURL>& sub_scopes, 927 const blink::WebVector<blink::WebURL>& sub_scopes,
928 const blink::WebVector<blink::WebSecurityOrigin>& origins) { 928 const blink::WebVector<blink::WebSecurityOrigin>& origins) {
929 Send(new ServiceWorkerHostMsg_RegisterForeignFetchScopes( 929 Send(new ServiceWorkerHostMsg_RegisterForeignFetchScopes(
930 GetRoutingID(), std::vector<GURL>(sub_scopes.begin(), sub_scopes.end()), 930 GetRoutingID(), std::vector<GURL>(sub_scopes.begin(), sub_scopes.end()),
931 std::vector<url::Origin>(origins.begin(), origins.end()))); 931 std::vector<url::Origin>(origins.begin(), origins.end())));
932 } 932 }
933 933
934 void ServiceWorkerContextClient::DispatchSyncEvent( 934 void ServiceWorkerContextClient::DispatchSyncEvent(
935 const std::string& tag, 935 const std::string& tag,
936 blink::WebServiceWorkerContextProxy::LastChanceOption last_chance, 936 blink::WebServiceWorkerContextProxy::LastChanceOption last_chance,
937 const SyncCallback& callback) { 937 const SyncCallback& callback) {
938 TRACE_EVENT0("ServiceWorker", 938 TRACE_EVENT0("ServiceWorker",
939 "ServiceWorkerContextClient::DispatchSyncEvent"); 939 "ServiceWorkerContextClient::DispatchSyncEvent");
940 int request_id = 940 int request_id = context_->sync_event_callbacks.Add(
941 context_->sync_event_callbacks.Add(new SyncCallback(callback)); 941 base::MakeUnique<SyncCallback>(callback));
942 942
943 // TODO(jkarlin): Make this blink::WebString::FromUTF8Lenient once 943 // TODO(jkarlin): Make this blink::WebString::FromUTF8Lenient once
944 // https://crrev.com/1768063002/ lands. 944 // https://crrev.com/1768063002/ lands.
945 proxy_->dispatchSyncEvent(request_id, blink::WebString::fromUTF8(tag), 945 proxy_->dispatchSyncEvent(request_id, blink::WebString::fromUTF8(tag),
946 last_chance); 946 last_chance);
947 } 947 }
948 948
949 void ServiceWorkerContextClient::Send(IPC::Message* message) { 949 void ServiceWorkerContextClient::Send(IPC::Message* message) {
950 sender_->Send(message); 950 sender_->Send(message);
951 } 951 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 1020
1021 void ServiceWorkerContextClient::DispatchFetchEvent( 1021 void ServiceWorkerContextClient::DispatchFetchEvent(
1022 int fetch_event_id, 1022 int fetch_event_id,
1023 const ServiceWorkerFetchRequest& request, 1023 const ServiceWorkerFetchRequest& request,
1024 std::unique_ptr<NavigationPreloadRequest> preload_request, 1024 std::unique_ptr<NavigationPreloadRequest> preload_request,
1025 const FetchCallback& callback) { 1025 const FetchCallback& callback) {
1026 const bool navigation_preload_sent = !!preload_request; 1026 const bool navigation_preload_sent = !!preload_request;
1027 blink::WebServiceWorkerRequest webRequest; 1027 blink::WebServiceWorkerRequest webRequest;
1028 TRACE_EVENT0("ServiceWorker", 1028 TRACE_EVENT0("ServiceWorker",
1029 "ServiceWorkerContextClient::DispatchFetchEvent"); 1029 "ServiceWorkerContextClient::DispatchFetchEvent");
1030 context_->fetch_event_callbacks.AddWithID(new FetchCallback(callback), 1030 context_->fetch_event_callbacks.AddWithID(
1031 fetch_event_id); 1031 base::MakeUnique<FetchCallback>(callback), fetch_event_id);
1032 if (preload_request) { 1032 if (preload_request) {
1033 context_->preload_requests.AddWithID(std::move(preload_request), 1033 context_->preload_requests.AddWithID(std::move(preload_request),
1034 fetch_event_id); 1034 fetch_event_id);
1035 } 1035 }
1036 1036
1037 webRequest.setURL(blink::WebURL(request.url)); 1037 webRequest.setURL(blink::WebURL(request.url));
1038 webRequest.setMethod(blink::WebString::fromUTF8(request.method)); 1038 webRequest.setMethod(blink::WebString::fromUTF8(request.method));
1039 for (ServiceWorkerHeaderMap::const_iterator it = request.headers.begin(); 1039 for (ServiceWorkerHeaderMap::const_iterator it = request.headers.begin();
1040 it != request.headers.end(); 1040 it != request.headers.end();
1041 ++it) { 1041 ++it) {
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 } 1305 }
1306 1306
1307 base::WeakPtr<ServiceWorkerContextClient> 1307 base::WeakPtr<ServiceWorkerContextClient>
1308 ServiceWorkerContextClient::GetWeakPtr() { 1308 ServiceWorkerContextClient::GetWeakPtr() {
1309 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 1309 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
1310 DCHECK(context_); 1310 DCHECK(context_);
1311 return context_->weak_factory.GetWeakPtr(); 1311 return context_->weak_factory.GetWeakPtr();
1312 } 1312 }
1313 1313
1314 } // namespace content 1314 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698