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

Side by Side Diff: chrome/browser/media/router/presentation_service_delegate_impl.cc

Issue 2706463002: [Presentation API] Mojo typemap for content::PresentationConnectionMessage (Closed)
Patch Set: Fix compile error after rebase Created 3 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 "chrome/browser/media/router/presentation_service_delegate_impl.h" 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <unordered_map> 8 #include <unordered_map>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 const MediaRoute::Id& route_id, 82 const MediaRoute::Id& route_id,
83 const content::PresentationConnectionMessageCallback& message_cb) 83 const content::PresentationConnectionMessageCallback& message_cb)
84 : RouteMessageObserver(router, route_id), message_cb_(message_cb) { 84 : RouteMessageObserver(router, route_id), message_cb_(message_cb) {
85 DCHECK(!message_cb_.is_null()); 85 DCHECK(!message_cb_.is_null());
86 } 86 }
87 87
88 ~PresentationSessionMessagesObserver() final {} 88 ~PresentationSessionMessagesObserver() final {}
89 89
90 void OnMessagesReceived(const std::vector<RouteMessage>& messages) final { 90 void OnMessagesReceived(const std::vector<RouteMessage>& messages) final {
91 DVLOG(2) << __func__ << ", number of messages : " << messages.size(); 91 DVLOG(2) << __func__ << ", number of messages : " << messages.size();
92 std::vector<std::unique_ptr<content::PresentationConnectionMessage>> 92 // TODO(mfoltz): Remove RouteMessage and replace with move-only
93 presentation_messages; 93 // PresentationConnectionMessage.
94 std::vector<content::PresentationConnectionMessage> presentation_messages;
94 for (const RouteMessage& message : messages) { 95 for (const RouteMessage& message : messages) {
95 if (message.type == RouteMessage::TEXT && message.text) { 96 if (message.type == RouteMessage::TEXT && message.text) {
96 presentation_messages.push_back( 97 presentation_messages.emplace_back(message.text.value());
97 base::MakeUnique<content::PresentationConnectionMessage>(
98 content::PresentationMessageType::TEXT));
99 presentation_messages.back()->message = *message.text;
100 } else if (message.type == RouteMessage::BINARY && message.binary) { 98 } else if (message.type == RouteMessage::BINARY && message.binary) {
101 presentation_messages.push_back( 99 presentation_messages.emplace_back(message.binary.value());
102 base::MakeUnique<content::PresentationConnectionMessage>( 100 } else {
103 content::PresentationMessageType::BINARY)); 101 NOTREACHED() << "Unknown route message type";
104 presentation_messages.back()->data.reset(
105 new std::vector<uint8_t>(*message.binary));
106 } 102 }
107 } 103 }
108 // TODO(miu): Remove second argument from PresentationSessionMessageCallback 104 message_cb_.Run(std::move(presentation_messages));
109 // since it's always true now.
110 message_cb_.Run(presentation_messages, true);
111 } 105 }
112 106
113 private: 107 private:
114 const content::PresentationConnectionMessageCallback message_cb_; 108 const content::PresentationConnectionMessageCallback message_cb_;
115 109
116 DISALLOW_COPY_AND_ASSIGN(PresentationSessionMessagesObserver); 110 DISALLOW_COPY_AND_ASSIGN(PresentationSessionMessagesObserver);
117 }; 111 };
118 112
119 } // namespace 113 } // namespace
120 114
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 const content::PresentationConnectionMessageCallback& message_cb) { 938 const content::PresentationConnectionMessageCallback& message_cb) {
945 frame_manager_->ListenForSessionMessages( 939 frame_manager_->ListenForSessionMessages(
946 RenderFrameHostId(render_process_id, render_frame_id), session, 940 RenderFrameHostId(render_process_id, render_frame_id), session,
947 message_cb); 941 message_cb);
948 } 942 }
949 943
950 void PresentationServiceDelegateImpl::SendMessage( 944 void PresentationServiceDelegateImpl::SendMessage(
951 int render_process_id, 945 int render_process_id,
952 int render_frame_id, 946 int render_frame_id,
953 const content::PresentationSessionInfo& session, 947 const content::PresentationSessionInfo& session,
954 std::unique_ptr<content::PresentationConnectionMessage> message, 948 content::PresentationConnectionMessage message,
955 const SendMessageCallback& send_message_cb) { 949 const SendMessageCallback& send_message_cb) {
956 const MediaRoute::Id& route_id = frame_manager_->GetRouteId( 950 const MediaRoute::Id& route_id = frame_manager_->GetRouteId(
957 RenderFrameHostId(render_process_id, render_frame_id), 951 RenderFrameHostId(render_process_id, render_frame_id),
958 session.presentation_id); 952 session.presentation_id);
959 if (route_id.empty()) { 953 if (route_id.empty()) {
960 DVLOG(1) << "No active route for " << session.presentation_id; 954 DVLOG(1) << "No active route for " << session.presentation_id;
961 send_message_cb.Run(false); 955 send_message_cb.Run(false);
962 return; 956 return;
963 } 957 }
964 958
965 if (message->is_binary()) { 959 if (message.is_binary()) {
966 router_->SendRouteBinaryMessage(route_id, std::move(message->data), 960 router_->SendRouteBinaryMessage(
967 send_message_cb); 961 route_id,
962 base::MakeUnique<std::vector<uint8_t>>(std::move(message.data.value())),
963 send_message_cb);
968 } else { 964 } else {
969 router_->SendRouteMessage(route_id, message->message, send_message_cb); 965 router_->SendRouteMessage(route_id, message.message.value(),
966 send_message_cb);
970 } 967 }
971 } 968 }
972 969
973 void PresentationServiceDelegateImpl::ListenForConnectionStateChange( 970 void PresentationServiceDelegateImpl::ListenForConnectionStateChange(
974 int render_process_id, 971 int render_process_id,
975 int render_frame_id, 972 int render_frame_id,
976 const content::PresentationSessionInfo& connection, 973 const content::PresentationSessionInfo& connection,
977 const content::PresentationConnectionStateChangedCallback& 974 const content::PresentationConnectionStateChangedCallback&
978 state_changed_cb) { 975 state_changed_cb) {
979 frame_manager_->ListenForConnectionStateChange( 976 frame_manager_->ListenForConnectionStateChange(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 const base::ListValue* origins = 1051 const base::ListValue* origins =
1055 Profile::FromBrowserContext(web_contents_->GetBrowserContext()) 1052 Profile::FromBrowserContext(web_contents_->GetBrowserContext())
1056 ->GetPrefs() 1053 ->GetPrefs()
1057 ->GetList(prefs::kMediaRouterTabMirroringSources); 1054 ->GetList(prefs::kMediaRouterTabMirroringSources);
1058 return origins && 1055 return origins &&
1059 origins->Find(base::StringValue(origin.Serialize())) != origins->end(); 1056 origins->Find(base::StringValue(origin.Serialize())) != origins->end();
1060 } 1057 }
1061 #endif // !defined(OS_ANDROID) 1058 #endif // !defined(OS_ANDROID)
1062 1059
1063 } // namespace media_router 1060 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/media/router/presentation_service_delegate_impl.h ('k') | chrome/browser/media/router/route_message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698