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

Side by Side Diff: content/child/navigator_connect/navigator_connect_provider.cc

Issue 944443003: Step two of optionally sending messages to/from message ports as base::Value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-c-message-as-values-take2
Patch Set: use auto where it makes sense Created 5 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/child/navigator_connect/navigator_connect_provider.h" 5 #include "content/child/navigator_connect/navigator_connect_provider.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/task_runner_util.h" 9 #include "base/task_runner_util.h"
10 #include "content/child/thread_safe_sender.h" 10 #include "content/child/thread_safe_sender.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (g_provider_tls.Pointer()->Get()) 70 if (g_provider_tls.Pointer()->Get())
71 return g_provider_tls.Pointer()->Get(); 71 return g_provider_tls.Pointer()->Get();
72 72
73 NavigatorConnectProvider* provider = 73 NavigatorConnectProvider* provider =
74 new NavigatorConnectProvider(thread_safe_sender, main_loop); 74 new NavigatorConnectProvider(thread_safe_sender, main_loop);
75 if (WorkerTaskRunner::Instance()->CurrentWorkerId()) 75 if (WorkerTaskRunner::Instance()->CurrentWorkerId())
76 WorkerTaskRunner::Instance()->AddStopObserver(provider); 76 WorkerTaskRunner::Instance()->AddStopObserver(provider);
77 return provider; 77 return provider;
78 } 78 }
79 79
80 void NavigatorConnectProvider::OnConnectResult(int thread_id, 80 void NavigatorConnectProvider::OnConnectResult(
81 int request_id, 81 int thread_id,
82 int message_port_id, 82 int request_id,
83 int message_port_route_id, 83 const TransferredMessagePort& message_port,
84 bool allow_connect) { 84 int message_port_route_id,
85 bool allow_connect) {
85 blink::WebNavigatorConnectPortCallbacks* callbacks = 86 blink::WebNavigatorConnectPortCallbacks* callbacks =
86 requests_.Lookup(request_id); 87 requests_.Lookup(request_id);
87 DCHECK(callbacks); 88 DCHECK(callbacks);
88 89
89 if (allow_connect) { 90 if (allow_connect) {
90 WebMessagePortChannelImpl* channel = new WebMessagePortChannelImpl( 91 WebMessagePortChannelImpl* channel = new WebMessagePortChannelImpl(
91 message_port_route_id, message_port_id, main_loop_); 92 message_port_route_id, message_port, main_loop_);
92 callbacks->onSuccess(channel); 93 callbacks->onSuccess(channel);
93 } else { 94 } else {
94 callbacks->onError(); 95 callbacks->onError();
95 } 96 }
96 requests_.Remove(request_id); 97 requests_.Remove(request_id);
97 } 98 }
98 99
99 void NavigatorConnectProvider::OnWorkerRunLoopStopped() { 100 void NavigatorConnectProvider::OnWorkerRunLoopStopped() {
100 delete this; 101 delete this;
101 } 102 }
102 103
103 } // namespace content 104 } // namespace content
OLDNEW
« no previous file with comments | « content/child/navigator_connect/navigator_connect_provider.h ('k') | content/child/service_worker/service_worker_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698