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

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

Issue 2574673002: Removes ScopedVector from presentation_service_impl. (Closed)
Patch Set: Addresses Avi's #3 comments. Created 4 years 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 MediaRouter* router, const MediaRoute::Id& route_id, 84 MediaRouter* router, const MediaRoute::Id& route_id,
85 const content::PresentationSessionMessageCallback& message_cb) 85 const content::PresentationSessionMessageCallback& message_cb)
86 : RouteMessageObserver(router, route_id), message_cb_(message_cb) { 86 : RouteMessageObserver(router, route_id), message_cb_(message_cb) {
87 DCHECK(!message_cb_.is_null()); 87 DCHECK(!message_cb_.is_null());
88 } 88 }
89 89
90 ~PresentationSessionMessagesObserver() final {} 90 ~PresentationSessionMessagesObserver() final {}
91 91
92 void OnMessagesReceived(const std::vector<RouteMessage>& messages) final { 92 void OnMessagesReceived(const std::vector<RouteMessage>& messages) final {
93 DVLOG(2) << __func__ << ", number of messages : " << messages.size(); 93 DVLOG(2) << __func__ << ", number of messages : " << messages.size();
94 ScopedVector<content::PresentationSessionMessage> presentation_messages; 94 std::vector<std::unique_ptr<content::PresentationSessionMessage>>
95 presentation_messages;
95 for (const RouteMessage& message : messages) { 96 for (const RouteMessage& message : messages) {
96 if (message.type == RouteMessage::TEXT && message.text) { 97 if (message.type == RouteMessage::TEXT && message.text) {
97 presentation_messages.push_back(new content::PresentationSessionMessage( 98 presentation_messages.push_back(
98 content::PresentationMessageType::TEXT)); 99 base::MakeUnique<content::PresentationSessionMessage>(
100 content::PresentationMessageType::TEXT));
99 presentation_messages.back()->message = *message.text; 101 presentation_messages.back()->message = *message.text;
100 } else if (message.type == RouteMessage::BINARY && message.binary) { 102 } else if (message.type == RouteMessage::BINARY && message.binary) {
101 presentation_messages.push_back(new content::PresentationSessionMessage( 103 presentation_messages.push_back(
102 content::PresentationMessageType::ARRAY_BUFFER)); 104 base::MakeUnique<content::PresentationSessionMessage>(
105 content::PresentationMessageType::ARRAY_BUFFER));
103 presentation_messages.back()->data.reset( 106 presentation_messages.back()->data.reset(
104 new std::vector<uint8_t>(*message.binary)); 107 new std::vector<uint8_t>(*message.binary));
105 } 108 }
106 } 109 }
107 // TODO(miu): Remove second argument from PresentationSessionMessageCallback 110 // TODO(miu): Remove second argument from PresentationSessionMessageCallback
108 // since it's always true now. 111 // since it's always true now.
109 message_cb_.Run(presentation_messages, true); 112 message_cb_.Run(presentation_messages, true);
110 } 113 }
111 114
112 private: 115 private:
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 const base::ListValue* origins = 1002 const base::ListValue* origins =
1000 Profile::FromBrowserContext(web_contents_->GetBrowserContext()) 1003 Profile::FromBrowserContext(web_contents_->GetBrowserContext())
1001 ->GetPrefs() 1004 ->GetPrefs()
1002 ->GetList(prefs::kMediaRouterTabMirroringSources); 1005 ->GetList(prefs::kMediaRouterTabMirroringSources);
1003 return origins && 1006 return origins &&
1004 origins->Find(base::StringValue(origin.Serialize())) != origins->end(); 1007 origins->Find(base::StringValue(origin.Serialize())) != origins->end();
1005 } 1008 }
1006 #endif // !defined(OS_ANDROID) 1009 #endif // !defined(OS_ANDROID)
1007 1010
1008 } // namespace media_router 1011 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698