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

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 in presentation_connection_message Created 3 years, 10 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 std::vector<content::PresentationConnectionMessage> presentation_messages;
93 presentation_messages; 93 // TODO(mfoltz): Figure out how to move message contents
94 for (const RouteMessage& message : messages) { 94 for (const RouteMessage& message : messages) {
95 if (message.type == RouteMessage::TEXT && message.text) { 95 if (message.type == RouteMessage::TEXT && message.text) {
96 presentation_messages.push_back( 96 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) { 97 } else if (message.type == RouteMessage::BINARY && message.binary) {
101 presentation_messages.push_back( 98 presentation_messages.emplace_back(message.binary.value());
102 base::MakeUnique<content::PresentationConnectionMessage>( 99 } else {
103 content::PresentationMessageType::BINARY)); 100 NOTREACHED() << "Unknown route message type";
104 presentation_messages.back()->data.reset(
105 new std::vector<uint8_t>(*message.binary));
106 } 101 }
107 } 102 }
108 // TODO(miu): Remove second argument from PresentationSessionMessageCallback 103 message_cb_.Run(presentation_messages);
109 // since it's always true now.
110 message_cb_.Run(presentation_messages, true);
111 } 104 }
112 105
113 private: 106 private:
114 const content::PresentationConnectionMessageCallback message_cb_; 107 const content::PresentationConnectionMessageCallback message_cb_;
115 108
116 DISALLOW_COPY_AND_ASSIGN(PresentationSessionMessagesObserver); 109 DISALLOW_COPY_AND_ASSIGN(PresentationSessionMessagesObserver);
117 }; 110 };
118 111
119 } // namespace 112 } // namespace
120 113
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 const content::PresentationConnectionMessageCallback& message_cb) { 937 const content::PresentationConnectionMessageCallback& message_cb) {
945 frame_manager_->ListenForSessionMessages( 938 frame_manager_->ListenForSessionMessages(
946 RenderFrameHostId(render_process_id, render_frame_id), session, 939 RenderFrameHostId(render_process_id, render_frame_id), session,
947 message_cb); 940 message_cb);
948 } 941 }
949 942
950 void PresentationServiceDelegateImpl::SendMessage( 943 void PresentationServiceDelegateImpl::SendMessage(
951 int render_process_id, 944 int render_process_id,
952 int render_frame_id, 945 int render_frame_id,
953 const content::PresentationSessionInfo& session, 946 const content::PresentationSessionInfo& session,
954 std::unique_ptr<content::PresentationConnectionMessage> message, 947 const content::PresentationConnectionMessage& message,
955 const SendMessageCallback& send_message_cb) { 948 const SendMessageCallback& send_message_cb) {
956 const MediaRoute::Id& route_id = frame_manager_->GetRouteId( 949 const MediaRoute::Id& route_id = frame_manager_->GetRouteId(
957 RenderFrameHostId(render_process_id, render_frame_id), 950 RenderFrameHostId(render_process_id, render_frame_id),
958 session.presentation_id); 951 session.presentation_id);
959 if (route_id.empty()) { 952 if (route_id.empty()) {
960 DVLOG(1) << "No active route for " << session.presentation_id; 953 DVLOG(1) << "No active route for " << session.presentation_id;
961 send_message_cb.Run(false); 954 send_message_cb.Run(false);
962 return; 955 return;
963 } 956 }
964 957
965 if (message->is_binary()) { 958 if (message.is_binary()) {
966 router_->SendRouteBinaryMessage(route_id, std::move(message->data), 959 router_->SendRouteBinaryMessage(route_id, message.data.value(),
967 send_message_cb); 960 send_message_cb);
968 } else { 961 } else {
969 router_->SendRouteMessage(route_id, message->message, send_message_cb); 962 router_->SendRouteMessage(route_id, message.message.value(),
963 send_message_cb);
970 } 964 }
971 } 965 }
972 966
973 void PresentationServiceDelegateImpl::ListenForConnectionStateChange( 967 void PresentationServiceDelegateImpl::ListenForConnectionStateChange(
974 int render_process_id, 968 int render_process_id,
975 int render_frame_id, 969 int render_frame_id,
976 const content::PresentationSessionInfo& connection, 970 const content::PresentationSessionInfo& connection,
977 const content::PresentationConnectionStateChangedCallback& 971 const content::PresentationConnectionStateChangedCallback&
978 state_changed_cb) { 972 state_changed_cb) {
979 frame_manager_->ListenForConnectionStateChange( 973 frame_manager_->ListenForConnectionStateChange(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 const base::ListValue* origins = 1048 const base::ListValue* origins =
1055 Profile::FromBrowserContext(web_contents_->GetBrowserContext()) 1049 Profile::FromBrowserContext(web_contents_->GetBrowserContext())
1056 ->GetPrefs() 1050 ->GetPrefs()
1057 ->GetList(prefs::kMediaRouterTabMirroringSources); 1051 ->GetList(prefs::kMediaRouterTabMirroringSources);
1058 return origins && 1052 return origins &&
1059 origins->Find(base::StringValue(origin.Serialize())) != origins->end(); 1053 origins->Find(base::StringValue(origin.Serialize())) != origins->end();
1060 } 1054 }
1061 #endif // !defined(OS_ANDROID) 1055 #endif // !defined(OS_ANDROID)
1062 1056
1063 } // namespace media_router 1057 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698