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

Side by Side Diff: content/browser/navigator_connect/navigator_connect_context_impl.cc

Issue 938403005: Make it possible for a navigator.connect service to receive messages as base::Value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-c-message-as-values-pass-flag
Patch Set: mention bug 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/browser/navigator_connect/navigator_connect_context_impl.h" 5 #include "content/browser/navigator_connect/navigator_connect_context_impl.h"
6 6
7 #include "content/browser/message_port_message_filter.h" 7 #include "content/browser/message_port_message_filter.h"
8 #include "content/browser/message_port_service.h" 8 #include "content/browser/message_port_service.h"
9 #include "content/public/browser/navigator_connect_service_factory.h" 9 #include "content/public/browser/navigator_connect_service_factory.h"
10 #include "content/public/common/navigator_connect_client.h" 10 #include "content/public/common/navigator_connect_client.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 for (auto it = service_factories_.rbegin(); it != service_factories_.rend(); 61 for (auto it = service_factories_.rbegin(); it != service_factories_.rend();
62 ++it) { 62 ++it) {
63 if ((*it)->HandlesUrl(client.target_url)) { 63 if ((*it)->HandlesUrl(client.target_url)) {
64 factory = *it; 64 factory = *it;
65 break; 65 break;
66 } 66 }
67 } 67 }
68 68
69 if (!factory) { 69 if (!factory) {
70 // No factories found. 70 // No factories found.
71 OnConnectResult(client, client_port, client_port_route_id, 71 OnConnectResult(client, client_port, client_port_route_id, callback,
72 callback, nullptr); 72 nullptr, false);
73 return; 73 return;
74 } 74 }
75 75
76 // Actually initiate connection. 76 // Actually initiate connection.
77 factory->Connect( 77 factory->Connect(
78 client, base::Bind(&NavigatorConnectContextImpl::OnConnectResult, this, 78 client, base::Bind(&NavigatorConnectContextImpl::OnConnectResult, this,
79 client, client_port, client_port_route_id, callback)); 79 client, client_port, client_port_route_id, callback));
80 } 80 }
81 81
82 void NavigatorConnectContextImpl::OnConnectResult( 82 void NavigatorConnectContextImpl::OnConnectResult(
83 const NavigatorConnectClient& client, 83 const NavigatorConnectClient& client,
84 int client_message_port_id, 84 int client_message_port_id,
85 int client_port_route_id, 85 int client_port_route_id,
86 const ConnectCallback& callback, 86 const ConnectCallback& callback,
87 MessagePortDelegate* delegate) { 87 MessagePortDelegate* delegate,
88 bool data_as_values) {
88 DCHECK_CURRENTLY_ON(BrowserThread::IO); 89 DCHECK_CURRENTLY_ON(BrowserThread::IO);
89 if (delegate) { 90 if (delegate) {
90 // Update service side port with delegate. 91 // Update service side port with delegate.
91 MessagePortService::GetInstance()->UpdateMessagePort( 92 MessagePortService::GetInstance()->UpdateMessagePort(
92 client.message_port_id, delegate, client.message_port_id); 93 client.message_port_id, delegate, client.message_port_id);
93 TransferredMessagePort port; 94 TransferredMessagePort port;
94 port.id = client_message_port_id; 95 port.id = client_message_port_id;
95 // TODO(mek): Set port.send_value_as_messages depending on connect result. 96 port.send_messages_as_values = data_as_values;
96 callback.Run(port, client_port_route_id, true); 97 callback.Run(port, client_port_route_id, true);
97 } else { 98 } else {
98 // Destroy ports since connection failed. 99 // Destroy ports since connection failed.
99 MessagePortService::GetInstance()->Destroy(client.message_port_id); 100 MessagePortService::GetInstance()->Destroy(client.message_port_id);
100 MessagePortService::GetInstance()->Destroy(client_message_port_id); 101 MessagePortService::GetInstance()->Destroy(client_message_port_id);
101 callback.Run(TransferredMessagePort(), MSG_ROUTING_NONE, false); 102 callback.Run(TransferredMessagePort(), MSG_ROUTING_NONE, false);
102 } 103 }
103 } 104 }
104 105
105 } // namespace content 106 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698