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

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

Issue 1815363002: Add RetainedRef uses where needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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 <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 void ServiceWorkerContextClient::postMessageToClient( 614 void ServiceWorkerContextClient::postMessageToClient(
615 const blink::WebString& uuid, 615 const blink::WebString& uuid,
616 const blink::WebString& message, 616 const blink::WebString& message,
617 blink::WebMessagePortChannelArray* channels) { 617 blink::WebMessagePortChannelArray* channels) {
618 // This may send channels for MessagePorts, and all internal book-keeping 618 // This may send channels for MessagePorts, and all internal book-keeping
619 // messages for MessagePort (e.g. QueueMessages) are sent from main thread 619 // messages for MessagePort (e.g. QueueMessages) are sent from main thread
620 // (with thread hopping), so we need to do the same thread hopping here not 620 // (with thread hopping), so we need to do the same thread hopping here not
621 // to overtake those messages. 621 // to overtake those messages.
622 scoped_ptr<blink::WebMessagePortChannelArray> channel_array(channels); 622 scoped_ptr<blink::WebMessagePortChannelArray> channel_array(channels);
623 main_thread_task_runner_->PostTask( 623 main_thread_task_runner_->PostTask(
624 FROM_HERE, 624 FROM_HERE, base::Bind(&SendPostMessageToClientOnMainThread,
625 base::Bind(&SendPostMessageToClientOnMainThread, 625 base::RetainedRef(sender_), GetRoutingID(),
626 sender_, 626 base::UTF16ToUTF8(base::StringPiece16(uuid)),
627 GetRoutingID(), 627 static_cast<base::string16>(message),
628 base::UTF16ToUTF8(base::StringPiece16(uuid)), 628 base::Passed(&channel_array)));
629 static_cast<base::string16>(message),
630 base::Passed(&channel_array)));
631 } 629 }
632 630
633 void ServiceWorkerContextClient::postMessageToCrossOriginClient( 631 void ServiceWorkerContextClient::postMessageToCrossOriginClient(
634 const blink::WebCrossOriginServiceWorkerClient& client, 632 const blink::WebCrossOriginServiceWorkerClient& client,
635 const blink::WebString& message, 633 const blink::WebString& message,
636 blink::WebMessagePortChannelArray* channels) { 634 blink::WebMessagePortChannelArray* channels) {
637 // This may send channels for MessagePorts, and all internal book-keeping 635 // This may send channels for MessagePorts, and all internal book-keeping
638 // messages for MessagePort (e.g. QueueMessages) are sent from main thread 636 // messages for MessagePort (e.g. QueueMessages) are sent from main thread
639 // (with thread hopping), so we need to do the same thread hopping here not 637 // (with thread hopping), so we need to do the same thread hopping here not
640 // to overtake those messages. 638 // to overtake those messages.
641 scoped_ptr<blink::WebMessagePortChannelArray> channel_array(channels); 639 scoped_ptr<blink::WebMessagePortChannelArray> channel_array(channels);
642 main_thread_task_runner_->PostTask( 640 main_thread_task_runner_->PostTask(
643 FROM_HERE, 641 FROM_HERE, base::Bind(&SendCrossOriginMessageToClientOnMainThread,
644 base::Bind(&SendCrossOriginMessageToClientOnMainThread, 642 base::RetainedRef(sender_), client.clientID,
645 sender_, client.clientID, 643 static_cast<base::string16>(message),
646 static_cast<base::string16>(message), 644 base::Passed(&channel_array)));
647 base::Passed(&channel_array)));
648 } 645 }
649 646
650 void ServiceWorkerContextClient::focus( 647 void ServiceWorkerContextClient::focus(
651 const blink::WebString& uuid, 648 const blink::WebString& uuid,
652 blink::WebServiceWorkerClientCallbacks* callback) { 649 blink::WebServiceWorkerClientCallbacks* callback) {
653 DCHECK(callback); 650 DCHECK(callback);
654 int request_id = context_->client_callbacks.Add(callback); 651 int request_id = context_->client_callbacks.Add(callback);
655 Send(new ServiceWorkerHostMsg_FocusClient( 652 Send(new ServiceWorkerHostMsg_FocusClient(
656 GetRoutingID(), request_id, 653 GetRoutingID(), request_id,
657 base::UTF16ToUTF8(base::StringPiece16(uuid)))); 654 base::UTF16ToUTF8(base::StringPiece16(uuid))));
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 } 1088 }
1092 1089
1093 base::WeakPtr<ServiceWorkerContextClient> 1090 base::WeakPtr<ServiceWorkerContextClient>
1094 ServiceWorkerContextClient::GetWeakPtr() { 1091 ServiceWorkerContextClient::GetWeakPtr() {
1095 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 1092 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
1096 DCHECK(context_); 1093 DCHECK(context_);
1097 return context_->weak_factory.GetWeakPtr(); 1094 return context_->weak_factory.GetWeakPtr();
1098 } 1095 }
1099 1096
1100 } // namespace content 1097 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698