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

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

Issue 1259673002: Make UTF16ToASCII and UTF16TOUTF8 take a StringPiece (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 // This may send channels for MessagePorts, and all internal book-keeping 548 // This may send channels for MessagePorts, and all internal book-keeping
549 // messages for MessagePort (e.g. QueueMessages) are sent from main thread 549 // messages for MessagePort (e.g. QueueMessages) are sent from main thread
550 // (with thread hopping), so we need to do the same thread hopping here not 550 // (with thread hopping), so we need to do the same thread hopping here not
551 // to overtake those messages. 551 // to overtake those messages.
552 scoped_ptr<blink::WebMessagePortChannelArray> channel_array(channels); 552 scoped_ptr<blink::WebMessagePortChannelArray> channel_array(channels);
553 main_thread_task_runner_->PostTask( 553 main_thread_task_runner_->PostTask(
554 FROM_HERE, 554 FROM_HERE,
555 base::Bind(&SendPostMessageToClientOnMainThread, 555 base::Bind(&SendPostMessageToClientOnMainThread,
556 sender_, 556 sender_,
557 GetRoutingID(), 557 GetRoutingID(),
558 base::UTF16ToUTF8(uuid), 558 base::UTF16ToUTF8(base::StringPiece16(uuid)),
559 static_cast<base::string16>(message), 559 static_cast<base::string16>(message),
560 base::Passed(&channel_array))); 560 base::Passed(&channel_array)));
561 } 561 }
562 562
563 void ServiceWorkerContextClient::postMessageToCrossOriginClient( 563 void ServiceWorkerContextClient::postMessageToCrossOriginClient(
564 const blink::WebCrossOriginServiceWorkerClient& client, 564 const blink::WebCrossOriginServiceWorkerClient& client,
565 const blink::WebString& message, 565 const blink::WebString& message,
566 blink::WebMessagePortChannelArray* channels) { 566 blink::WebMessagePortChannelArray* channels) {
567 // This may send channels for MessagePorts, and all internal book-keeping 567 // This may send channels for MessagePorts, and all internal book-keeping
568 // messages for MessagePort (e.g. QueueMessages) are sent from main thread 568 // messages for MessagePort (e.g. QueueMessages) are sent from main thread
569 // (with thread hopping), so we need to do the same thread hopping here not 569 // (with thread hopping), so we need to do the same thread hopping here not
570 // to overtake those messages. 570 // to overtake those messages.
571 scoped_ptr<blink::WebMessagePortChannelArray> channel_array(channels); 571 scoped_ptr<blink::WebMessagePortChannelArray> channel_array(channels);
572 main_thread_task_runner_->PostTask( 572 main_thread_task_runner_->PostTask(
573 FROM_HERE, 573 FROM_HERE,
574 base::Bind(&SendCrossOriginMessageToClientOnMainThread, 574 base::Bind(&SendCrossOriginMessageToClientOnMainThread,
575 sender_, client.clientID, 575 sender_, client.clientID,
576 static_cast<base::string16>(message), 576 static_cast<base::string16>(message),
577 base::Passed(&channel_array))); 577 base::Passed(&channel_array)));
578 } 578 }
579 579
580 void ServiceWorkerContextClient::focus( 580 void ServiceWorkerContextClient::focus(
581 const blink::WebString& uuid, 581 const blink::WebString& uuid,
582 blink::WebServiceWorkerClientCallbacks* callback) { 582 blink::WebServiceWorkerClientCallbacks* callback) {
583 DCHECK(callback); 583 DCHECK(callback);
584 int request_id = context_->client_callbacks.Add(callback); 584 int request_id = context_->client_callbacks.Add(callback);
585 Send(new ServiceWorkerHostMsg_FocusClient(GetRoutingID(), request_id, 585 Send(new ServiceWorkerHostMsg_FocusClient(
586 base::UTF16ToUTF8(uuid))); 586 GetRoutingID(), request_id,
587 base::UTF16ToUTF8(base::StringPiece16(uuid))));
587 } 588 }
588 589
589 void ServiceWorkerContextClient::skipWaiting( 590 void ServiceWorkerContextClient::skipWaiting(
590 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks) { 591 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks) {
591 DCHECK(callbacks); 592 DCHECK(callbacks);
592 int request_id = context_->skip_waiting_callbacks.Add(callbacks); 593 int request_id = context_->skip_waiting_callbacks.Add(callbacks);
593 Send(new ServiceWorkerHostMsg_SkipWaiting(GetRoutingID(), request_id)); 594 Send(new ServiceWorkerHostMsg_SkipWaiting(GetRoutingID(), request_id));
594 } 595 }
595 596
596 void ServiceWorkerContextClient::claim( 597 void ServiceWorkerContextClient::claim(
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 } 903 }
903 904
904 base::WeakPtr<ServiceWorkerContextClient> 905 base::WeakPtr<ServiceWorkerContextClient>
905 ServiceWorkerContextClient::GetWeakPtr() { 906 ServiceWorkerContextClient::GetWeakPtr() {
906 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 907 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
907 DCHECK(context_); 908 DCHECK(context_);
908 return context_->weak_factory.GetWeakPtr(); 909 return context_->weak_factory.GetWeakPtr();
909 } 910 }
910 911
911 } // namespace content 912 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/renderer_webcookiejar_impl.cc ('k') | content/renderer/service_worker/service_worker_type_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698