OLD | NEW |
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 "content/browser/presentation/presentation_service_impl.h" | 5 #include "content/browser/presentation/presentation_service_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 output->type = mojom::PresentationMessageType::TEXT; | 58 output->type = mojom::PresentationMessageType::TEXT; |
59 if (pass_ownership) { | 59 if (pass_ownership) { |
60 output->message.Swap(&input->message); | 60 output->message.Swap(&input->message); |
61 } else { | 61 } else { |
62 output->message = input->message; | 62 output->message = input->message; |
63 } | 63 } |
64 } | 64 } |
65 return output; | 65 return output; |
66 } | 66 } |
67 | 67 |
68 scoped_ptr<PresentationSessionMessage> GetPresentationSessionMessage( | 68 std::unique_ptr<PresentationSessionMessage> GetPresentationSessionMessage( |
69 mojom::SessionMessagePtr input) { | 69 mojom::SessionMessagePtr input) { |
70 DCHECK(!input.is_null()); | 70 DCHECK(!input.is_null()); |
71 scoped_ptr<content::PresentationSessionMessage> output; | 71 std::unique_ptr<content::PresentationSessionMessage> output; |
72 switch (input->type) { | 72 switch (input->type) { |
73 case mojom::PresentationMessageType::TEXT: { | 73 case mojom::PresentationMessageType::TEXT: { |
74 DCHECK(!input->message.is_null()); | 74 DCHECK(!input->message.is_null()); |
75 DCHECK(input->data.is_null()); | 75 DCHECK(input->data.is_null()); |
76 // Return null PresentationSessionMessage if size exceeds. | 76 // Return null PresentationSessionMessage if size exceeds. |
77 if (input->message.size() > content::kMaxPresentationSessionMessageSize) | 77 if (input->message.size() > content::kMaxPresentationSessionMessageSize) |
78 return output; | 78 return output; |
79 | 79 |
80 output.reset( | 80 output.reset( |
81 new PresentationSessionMessage(PresentationMessageType::TEXT)); | 81 new PresentationSessionMessage(PresentationMessageType::TEXT)); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 DVLOG(2) << "ListenForScreenAvailability " << url; | 187 DVLOG(2) << "ListenForScreenAvailability " << url; |
188 if (!delegate_) { | 188 if (!delegate_) { |
189 client_->OnScreenAvailabilityUpdated(url, false); | 189 client_->OnScreenAvailabilityUpdated(url, false); |
190 return; | 190 return; |
191 } | 191 } |
192 | 192 |
193 const std::string& availability_url = url.get(); | 193 const std::string& availability_url = url.get(); |
194 if (screen_availability_listeners_.count(availability_url)) | 194 if (screen_availability_listeners_.count(availability_url)) |
195 return; | 195 return; |
196 | 196 |
197 scoped_ptr<ScreenAvailabilityListenerImpl> listener( | 197 std::unique_ptr<ScreenAvailabilityListenerImpl> listener( |
198 new ScreenAvailabilityListenerImpl(availability_url, this)); | 198 new ScreenAvailabilityListenerImpl(availability_url, this)); |
199 if (delegate_->AddScreenAvailabilityListener( | 199 if (delegate_->AddScreenAvailabilityListener( |
200 render_process_id_, | 200 render_process_id_, |
201 render_frame_id_, | 201 render_frame_id_, |
202 listener.get())) { | 202 listener.get())) { |
203 screen_availability_listeners_[availability_url] = std::move(listener); | 203 screen_availability_listeners_[availability_url] = std::move(listener); |
204 } else { | 204 } else { |
205 DVLOG(1) << "AddScreenAvailabilityListener failed. Ignoring request."; | 205 DVLOG(1) << "AddScreenAvailabilityListener failed. Ignoring request."; |
206 } | 206 } |
207 } | 207 } |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 597 |
598 void PresentationServiceImpl::NewSessionMojoCallbackWrapper::Run( | 598 void PresentationServiceImpl::NewSessionMojoCallbackWrapper::Run( |
599 mojom::PresentationSessionInfoPtr session, | 599 mojom::PresentationSessionInfoPtr session, |
600 mojom::PresentationErrorPtr error) { | 600 mojom::PresentationErrorPtr error) { |
601 DCHECK(!callback_.is_null()); | 601 DCHECK(!callback_.is_null()); |
602 callback_.Run(std::move(session), std::move(error)); | 602 callback_.Run(std::move(session), std::move(error)); |
603 callback_.reset(); | 603 callback_.reset(); |
604 } | 604 } |
605 | 605 |
606 } // namespace content | 606 } // namespace content |
OLD | NEW |