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

Side by Side Diff: content/renderer/presentation/presentation_dispatcher.cc

Issue 2622993002: [Presentation API] Move presentation.mojom to content/common/presentation (Closed)
Patch Set: Fix presentation_service_delegate. DEPS failure Created 3 years, 11 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 "content/renderer/presentation/presentation_dispatcher.h" 5 #include "content/renderer/presentation/presentation_dispatcher.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "content/public/common/presentation_constants.h" 15 #include "content/public/common/presentation_constants.h"
16 #include "content/public/renderer/render_frame.h" 16 #include "content/public/renderer/render_frame.h"
17 #include "mojo/public/cpp/bindings/type_converter.h" 17 #include "mojo/public/cpp/bindings/type_converter.h"
18 #include "services/service_manager/public/cpp/interface_provider.h" 18 #include "services/service_manager/public/cpp/interface_provider.h"
19 #include "third_party/WebKit/public/platform/WebString.h" 19 #include "third_party/WebKit/public/platform/WebString.h"
20 #include "third_party/WebKit/public/platform/WebURL.h" 20 #include "third_party/WebKit/public/platform/WebURL.h"
21 #include "third_party/WebKit/public/platform/WebVector.h" 21 #include "third_party/WebKit/public/platform/WebVector.h"
22 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nAvailabilityObserver.h" 22 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nAvailabilityObserver.h"
23 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nController.h" 23 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nController.h"
24 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nError.h" 24 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nError.h"
25 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nReceiver.h" 25 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nReceiver.h"
26 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nSessionInfo.h" 26 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nSessionInfo.h"
27 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h"
28 #include "third_party/WebKit/public/web/WebLocalFrame.h" 27 #include "third_party/WebKit/public/web/WebLocalFrame.h"
29 #include "url/gurl.h" 28 #include "url/gurl.h"
30 29
31 namespace mojo { 30 namespace mojo {
32 31
33 // Temporary type converter since Presentation API has not been Onion Soup-ed. 32 // Temporary type converter since Presentation API has not been Onion Soup-ed.
34 template <> 33 template <>
35 struct TypeConverter<blink::WebPresentationSessionInfo, 34 struct TypeConverter<blink::WebPresentationSessionInfo,
36 blink::mojom::PresentationSessionInfoPtr> { 35 content::mojom::PresentationSessionInfoPtr> {
37 static blink::WebPresentationSessionInfo Convert( 36 static blink::WebPresentationSessionInfo Convert(
38 const blink::mojom::PresentationSessionInfoPtr& input) { 37 const content::mojom::PresentationSessionInfoPtr& input) {
39 return blink::WebPresentationSessionInfo( 38 return blink::WebPresentationSessionInfo(
40 blink::WebURL(input->url), blink::WebString::fromUTF8(input->id)); 39 blink::WebURL(input->url), blink::WebString::fromUTF8(input->id));
41 } 40 }
42 }; 41 };
43 42
44 } // namespace mojo 43 } // namespace mojo
45 44
46 namespace { 45 namespace {
47 46
48 blink::WebPresentationError::ErrorType GetWebPresentationErrorTypeFromMojo( 47 blink::WebPresentationError::ErrorType GetWebPresentationErrorTypeFromMojo(
49 blink::mojom::PresentationErrorType mojoErrorType) { 48 content::mojom::PresentationErrorType mojoErrorType) {
50 switch (mojoErrorType) { 49 switch (mojoErrorType) {
51 case blink::mojom::PresentationErrorType::NO_AVAILABLE_SCREENS: 50 case content::mojom::PresentationErrorType::NO_AVAILABLE_SCREENS:
52 return blink::WebPresentationError::ErrorTypeNoAvailableScreens; 51 return blink::WebPresentationError::ErrorTypeNoAvailableScreens;
53 case blink::mojom::PresentationErrorType::SESSION_REQUEST_CANCELLED: 52 case content::mojom::PresentationErrorType::SESSION_REQUEST_CANCELLED:
54 return blink::WebPresentationError::ErrorTypeSessionRequestCancelled; 53 return blink::WebPresentationError::ErrorTypeSessionRequestCancelled;
55 case blink::mojom::PresentationErrorType::NO_PRESENTATION_FOUND: 54 case content::mojom::PresentationErrorType::NO_PRESENTATION_FOUND:
56 return blink::WebPresentationError::ErrorTypeNoPresentationFound; 55 return blink::WebPresentationError::ErrorTypeNoPresentationFound;
57 case blink::mojom::PresentationErrorType::UNKNOWN: 56 case content::mojom::PresentationErrorType::UNKNOWN:
58 default: 57 default:
59 return blink::WebPresentationError::ErrorTypeUnknown; 58 return blink::WebPresentationError::ErrorTypeUnknown;
60 } 59 }
61 } 60 }
62 61
63 blink::WebPresentationConnectionState GetWebPresentationConnectionStateFromMojo( 62 blink::WebPresentationConnectionState GetWebPresentationConnectionStateFromMojo(
64 blink::mojom::PresentationConnectionState mojoSessionState) { 63 content::mojom::PresentationConnectionState mojoSessionState) {
65 switch (mojoSessionState) { 64 switch (mojoSessionState) {
66 case blink::mojom::PresentationConnectionState::CONNECTING: 65 case content::mojom::PresentationConnectionState::CONNECTING:
67 return blink::WebPresentationConnectionState::Connecting; 66 return blink::WebPresentationConnectionState::Connecting;
68 case blink::mojom::PresentationConnectionState::CONNECTED: 67 case content::mojom::PresentationConnectionState::CONNECTED:
69 return blink::WebPresentationConnectionState::Connected; 68 return blink::WebPresentationConnectionState::Connected;
70 case blink::mojom::PresentationConnectionState::CLOSED: 69 case content::mojom::PresentationConnectionState::CLOSED:
71 return blink::WebPresentationConnectionState::Closed; 70 return blink::WebPresentationConnectionState::Closed;
72 case blink::mojom::PresentationConnectionState::TERMINATED: 71 case content::mojom::PresentationConnectionState::TERMINATED:
73 return blink::WebPresentationConnectionState::Terminated; 72 return blink::WebPresentationConnectionState::Terminated;
74 default: 73 default:
75 NOTREACHED(); 74 NOTREACHED();
76 return blink::WebPresentationConnectionState::Terminated; 75 return blink::WebPresentationConnectionState::Terminated;
77 } 76 }
78 } 77 }
79 78
80 blink::WebPresentationConnectionCloseReason 79 blink::WebPresentationConnectionCloseReason
81 GetWebPresentationConnectionCloseReasonFromMojo( 80 GetWebPresentationConnectionCloseReasonFromMojo(
82 blink::mojom::PresentationConnectionCloseReason mojoConnectionCloseReason) { 81 content::mojom::PresentationConnectionCloseReason
82 mojoConnectionCloseReason) {
83 switch (mojoConnectionCloseReason) { 83 switch (mojoConnectionCloseReason) {
84 case blink::mojom::PresentationConnectionCloseReason::CONNECTION_ERROR: 84 case content::mojom::PresentationConnectionCloseReason::CONNECTION_ERROR:
85 return blink::WebPresentationConnectionCloseReason::Error; 85 return blink::WebPresentationConnectionCloseReason::Error;
86 case blink::mojom::PresentationConnectionCloseReason::CLOSED: 86 case content::mojom::PresentationConnectionCloseReason::CLOSED:
87 return blink::WebPresentationConnectionCloseReason::Closed; 87 return blink::WebPresentationConnectionCloseReason::Closed;
88 case blink::mojom::PresentationConnectionCloseReason::WENT_AWAY: 88 case content::mojom::PresentationConnectionCloseReason::WENT_AWAY:
89 return blink::WebPresentationConnectionCloseReason::WentAway; 89 return blink::WebPresentationConnectionCloseReason::WentAway;
90 default: 90 default:
91 NOTREACHED(); 91 NOTREACHED();
92 return blink::WebPresentationConnectionCloseReason::Error; 92 return blink::WebPresentationConnectionCloseReason::Error;
93 } 93 }
94 } 94 }
95 95
96 } // namespace 96 } // namespace
97 97
98 namespace content { 98 namespace content {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 size_t length) { 182 size_t length) {
183 DCHECK(data); 183 DCHECK(data);
184 if (length > kMaxPresentationConnectionMessageSize) { 184 if (length > kMaxPresentationConnectionMessageSize) {
185 // TODO(crbug.com/459008): Same as in sendString(). 185 // TODO(crbug.com/459008): Same as in sendString().
186 LOG(WARNING) << "data size exceeded limit!"; 186 LOG(WARNING) << "data size exceeded limit!";
187 return; 187 return;
188 } 188 }
189 189
190 message_request_queue_.push(base::WrapUnique(CreateSendBinaryMessageRequest( 190 message_request_queue_.push(base::WrapUnique(CreateSendBinaryMessageRequest(
191 presentationUrl, presentationId, 191 presentationUrl, presentationId,
192 blink::mojom::PresentationMessageType::BINARY, data, length))); 192 content::mojom::PresentationMessageType::BINARY, data, length)));
193 // Start processing request if only one in the queue. 193 // Start processing request if only one in the queue.
194 if (message_request_queue_.size() == 1) 194 if (message_request_queue_.size() == 1)
195 DoSendMessage(message_request_queue_.front().get()); 195 DoSendMessage(message_request_queue_.front().get());
196 } 196 }
197 197
198 void PresentationDispatcher::sendBlobData( 198 void PresentationDispatcher::sendBlobData(
199 const blink::WebURL& presentationUrl, 199 const blink::WebURL& presentationUrl,
200 const blink::WebString& presentationId, 200 const blink::WebString& presentationId,
201 const uint8_t* data, 201 const uint8_t* data,
202 size_t length) { 202 size_t length) {
203 DCHECK(data); 203 DCHECK(data);
204 if (length > kMaxPresentationConnectionMessageSize) { 204 if (length > kMaxPresentationConnectionMessageSize) {
205 // TODO(crbug.com/459008): Same as in sendString(). 205 // TODO(crbug.com/459008): Same as in sendString().
206 LOG(WARNING) << "data size exceeded limit!"; 206 LOG(WARNING) << "data size exceeded limit!";
207 return; 207 return;
208 } 208 }
209 209
210 message_request_queue_.push(base::WrapUnique(CreateSendBinaryMessageRequest( 210 message_request_queue_.push(base::WrapUnique(CreateSendBinaryMessageRequest(
211 presentationUrl, presentationId, 211 presentationUrl, presentationId,
212 blink::mojom::PresentationMessageType::BINARY, data, length))); 212 content::mojom::PresentationMessageType::BINARY, data, length)));
213 // Start processing request if only one in the queue. 213 // Start processing request if only one in the queue.
214 if (message_request_queue_.size() == 1) 214 if (message_request_queue_.size() == 1)
215 DoSendMessage(message_request_queue_.front().get()); 215 DoSendMessage(message_request_queue_.front().get());
216 } 216 }
217 217
218 void PresentationDispatcher::DoSendMessage(SendMessageRequest* request) { 218 void PresentationDispatcher::DoSendMessage(SendMessageRequest* request) {
219 ConnectToPresentationServiceIfNeeded(); 219 ConnectToPresentationServiceIfNeeded();
220 220
221 presentation_service_->SendConnectionMessage( 221 presentation_service_->SendConnectionMessage(
222 std::move(request->session_info), std::move(request->message), 222 std::move(request->session_info), std::move(request->message),
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 !iter.IsAtEnd(); iter.Advance()) { 382 !iter.IsAtEnd(); iter.Advance()) {
383 iter.GetCurrentValue()->onError(blink::WebPresentationError( 383 iter.GetCurrentValue()->onError(blink::WebPresentationError(
384 blink::WebPresentationError::ErrorTypeAvailabilityNotSupported, 384 blink::WebPresentationError::ErrorTypeAvailabilityNotSupported,
385 not_supported_error)); 385 not_supported_error));
386 } 386 }
387 status->availability_callbacks.Clear(); 387 status->availability_callbacks.Clear();
388 UpdateListeningState(status); 388 UpdateListeningState(status);
389 } 389 }
390 390
391 void PresentationDispatcher::OnDefaultSessionStarted( 391 void PresentationDispatcher::OnDefaultSessionStarted(
392 blink::mojom::PresentationSessionInfoPtr session_info) { 392 content::mojom::PresentationSessionInfoPtr session_info) {
393 if (!controller_) 393 if (!controller_)
394 return; 394 return;
395 395
396 if (!session_info.is_null()) { 396 if (!session_info.is_null()) {
397 presentation_service_->ListenForConnectionMessages(session_info.Clone()); 397 presentation_service_->ListenForConnectionMessages(session_info.Clone());
398 controller_->didStartDefaultSession( 398 controller_->didStartDefaultSession(
399 mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info)); 399 mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info));
400 } 400 }
401 } 401 }
402 402
403 void PresentationDispatcher::OnSessionCreated( 403 void PresentationDispatcher::OnSessionCreated(
404 std::unique_ptr<blink::WebPresentationConnectionCallback> callback, 404 std::unique_ptr<blink::WebPresentationConnectionCallback> callback,
405 blink::mojom::PresentationSessionInfoPtr session_info, 405 content::mojom::PresentationSessionInfoPtr session_info,
406 blink::mojom::PresentationErrorPtr error) { 406 content::mojom::PresentationErrorPtr error) {
407 DCHECK(callback); 407 DCHECK(callback);
408 if (!error.is_null()) { 408 if (!error.is_null()) {
409 DCHECK(session_info.is_null()); 409 DCHECK(session_info.is_null());
410 callback->onError(blink::WebPresentationError( 410 callback->onError(blink::WebPresentationError(
411 GetWebPresentationErrorTypeFromMojo(error->error_type), 411 GetWebPresentationErrorTypeFromMojo(error->error_type),
412 blink::WebString::fromUTF8(error->message))); 412 blink::WebString::fromUTF8(error->message)));
413 return; 413 return;
414 } 414 }
415 415
416 DCHECK(!session_info.is_null()); 416 DCHECK(!session_info.is_null());
417 presentation_service_->ListenForConnectionMessages(session_info.Clone()); 417 presentation_service_->ListenForConnectionMessages(session_info.Clone());
418 callback->onSuccess( 418 callback->onSuccess(
419 mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info)); 419 mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info));
420 } 420 }
421 421
422 void PresentationDispatcher::OnReceiverConnectionAvailable( 422 void PresentationDispatcher::OnReceiverConnectionAvailable(
423 blink::mojom::PresentationSessionInfoPtr session_info, 423 content::mojom::PresentationSessionInfoPtr session_info,
424 blink::mojom::PresentationConnectionPtr, 424 content::mojom::PresentationConnectionPtr,
425 blink::mojom::PresentationConnectionRequest) { 425 content::mojom::PresentationConnectionRequest) {
426 if (receiver_) { 426 if (receiver_) {
427 receiver_->onReceiverConnectionAvailable( 427 receiver_->onReceiverConnectionAvailable(
428 mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info)); 428 mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info));
429 } 429 }
430 } 430 }
431 431
432 void PresentationDispatcher::OnConnectionStateChanged( 432 void PresentationDispatcher::OnConnectionStateChanged(
433 blink::mojom::PresentationSessionInfoPtr session_info, 433 content::mojom::PresentationSessionInfoPtr session_info,
434 blink::mojom::PresentationConnectionState state) { 434 content::mojom::PresentationConnectionState state) {
435 if (!controller_) 435 if (!controller_)
436 return; 436 return;
437 437
438 controller_->didChangeSessionState( 438 controller_->didChangeSessionState(
439 mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info), 439 mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info),
440 GetWebPresentationConnectionStateFromMojo(state)); 440 GetWebPresentationConnectionStateFromMojo(state));
441 } 441 }
442 442
443 void PresentationDispatcher::OnConnectionClosed( 443 void PresentationDispatcher::OnConnectionClosed(
444 blink::mojom::PresentationSessionInfoPtr session_info, 444 content::mojom::PresentationSessionInfoPtr session_info,
445 blink::mojom::PresentationConnectionCloseReason reason, 445 content::mojom::PresentationConnectionCloseReason reason,
446 const std::string& message) { 446 const std::string& message) {
447 if (!controller_) 447 if (!controller_)
448 return; 448 return;
449 449
450 controller_->didCloseConnection( 450 controller_->didCloseConnection(
451 mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info), 451 mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info),
452 GetWebPresentationConnectionCloseReasonFromMojo(reason), 452 GetWebPresentationConnectionCloseReasonFromMojo(reason),
453 blink::WebString::fromUTF8(message)); 453 blink::WebString::fromUTF8(message));
454 } 454 }
455 455
456 void PresentationDispatcher::OnConnectionMessagesReceived( 456 void PresentationDispatcher::OnConnectionMessagesReceived(
457 blink::mojom::PresentationSessionInfoPtr session_info, 457 content::mojom::PresentationSessionInfoPtr session_info,
458 std::vector<blink::mojom::ConnectionMessagePtr> messages) { 458 std::vector<content::mojom::ConnectionMessagePtr> messages) {
459 if (!controller_) 459 if (!controller_)
460 return; 460 return;
461 461
462 for (size_t i = 0; i < messages.size(); ++i) { 462 for (size_t i = 0; i < messages.size(); ++i) {
463 // Note: Passing batches of messages to the Blink layer would be more 463 // Note: Passing batches of messages to the Blink layer would be more
464 // efficient. 464 // efficient.
465 auto web_session_info = 465 auto web_session_info =
466 mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info); 466 mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info);
467 switch (messages[i]->type) { 467 switch (messages[i]->type) {
468 case blink::mojom::PresentationMessageType::TEXT: { 468 case content::mojom::PresentationMessageType::TEXT: {
469 // TODO(mfoltz): Do we need to DCHECK(messages[i]->message)? 469 // TODO(mfoltz): Do we need to DCHECK(messages[i]->message)?
470 controller_->didReceiveSessionTextMessage( 470 controller_->didReceiveSessionTextMessage(
471 web_session_info, 471 web_session_info,
472 blink::WebString::fromUTF8(messages[i]->message.value())); 472 blink::WebString::fromUTF8(messages[i]->message.value()));
473 break; 473 break;
474 } 474 }
475 case blink::mojom::PresentationMessageType::BINARY: { 475 case content::mojom::PresentationMessageType::BINARY: {
476 // TODO(mfoltz): Do we need to DCHECK(messages[i]->data)? 476 // TODO(mfoltz): Do we need to DCHECK(messages[i]->data)?
477 controller_->didReceiveSessionBinaryMessage( 477 controller_->didReceiveSessionBinaryMessage(
478 web_session_info, &(messages[i]->data->front()), 478 web_session_info, &(messages[i]->data->front()),
479 messages[i]->data->size()); 479 messages[i]->data->size());
480 break; 480 break;
481 } 481 }
482 default: { 482 default: {
483 NOTREACHED(); 483 NOTREACHED();
484 break; 484 break;
485 } 485 }
(...skipping 21 matching lines...) Expand all
507 if (should_listen) { 507 if (should_listen) {
508 status->listening_state = ListeningState::WAITING; 508 status->listening_state = ListeningState::WAITING;
509 presentation_service_->ListenForScreenAvailability(status->url); 509 presentation_service_->ListenForScreenAvailability(status->url);
510 } else { 510 } else {
511 status->listening_state = ListeningState::INACTIVE; 511 status->listening_state = ListeningState::INACTIVE;
512 presentation_service_->StopListeningForScreenAvailability(status->url); 512 presentation_service_->StopListeningForScreenAvailability(status->url);
513 } 513 }
514 } 514 }
515 515
516 PresentationDispatcher::SendMessageRequest::SendMessageRequest( 516 PresentationDispatcher::SendMessageRequest::SendMessageRequest(
517 blink::mojom::PresentationSessionInfoPtr session_info, 517 content::mojom::PresentationSessionInfoPtr session_info,
518 blink::mojom::ConnectionMessagePtr message) 518 content::mojom::ConnectionMessagePtr message)
519 : session_info(std::move(session_info)), message(std::move(message)) {} 519 : session_info(std::move(session_info)), message(std::move(message)) {}
520 520
521 PresentationDispatcher::SendMessageRequest::~SendMessageRequest() {} 521 PresentationDispatcher::SendMessageRequest::~SendMessageRequest() {}
522 522
523 // static 523 // static
524 PresentationDispatcher::SendMessageRequest* 524 PresentationDispatcher::SendMessageRequest*
525 PresentationDispatcher::CreateSendTextMessageRequest( 525 PresentationDispatcher::CreateSendTextMessageRequest(
526 const blink::WebURL& presentationUrl, 526 const blink::WebURL& presentationUrl,
527 const blink::WebString& presentationId, 527 const blink::WebString& presentationId,
528 const blink::WebString& message) { 528 const blink::WebString& message) {
529 blink::mojom::PresentationSessionInfoPtr session_info = 529 content::mojom::PresentationSessionInfoPtr session_info =
530 blink::mojom::PresentationSessionInfo::New(); 530 content::mojom::PresentationSessionInfo::New();
531 session_info->url = presentationUrl; 531 session_info->url = presentationUrl;
532 session_info->id = presentationId.utf8(); 532 session_info->id = presentationId.utf8();
533 533
534 blink::mojom::ConnectionMessagePtr session_message = 534 content::mojom::ConnectionMessagePtr session_message =
535 blink::mojom::ConnectionMessage::New(); 535 content::mojom::ConnectionMessage::New();
536 session_message->type = blink::mojom::PresentationMessageType::TEXT; 536 session_message->type = content::mojom::PresentationMessageType::TEXT;
537 session_message->message = message.utf8(); 537 session_message->message = message.utf8();
538 return new SendMessageRequest(std::move(session_info), 538 return new SendMessageRequest(std::move(session_info),
539 std::move(session_message)); 539 std::move(session_message));
540 } 540 }
541 541
542 // static 542 // static
543 PresentationDispatcher::SendMessageRequest* 543 PresentationDispatcher::SendMessageRequest*
544 PresentationDispatcher::CreateSendBinaryMessageRequest( 544 PresentationDispatcher::CreateSendBinaryMessageRequest(
545 const blink::WebURL& presentationUrl, 545 const blink::WebURL& presentationUrl,
546 const blink::WebString& presentationId, 546 const blink::WebString& presentationId,
547 blink::mojom::PresentationMessageType type, 547 content::mojom::PresentationMessageType type,
548 const uint8_t* data, 548 const uint8_t* data,
549 size_t length) { 549 size_t length) {
550 blink::mojom::PresentationSessionInfoPtr session_info = 550 content::mojom::PresentationSessionInfoPtr session_info =
551 blink::mojom::PresentationSessionInfo::New(); 551 content::mojom::PresentationSessionInfo::New();
552 session_info->url = presentationUrl; 552 session_info->url = presentationUrl;
553 session_info->id = presentationId.utf8(); 553 session_info->id = presentationId.utf8();
554 554
555 blink::mojom::ConnectionMessagePtr session_message = 555 content::mojom::ConnectionMessagePtr session_message =
556 blink::mojom::ConnectionMessage::New(); 556 content::mojom::ConnectionMessage::New();
557 session_message->type = type; 557 session_message->type = type;
558 session_message->data = std::vector<uint8_t>(data, data + length); 558 session_message->data = std::vector<uint8_t>(data, data + length);
559 return new SendMessageRequest(std::move(session_info), 559 return new SendMessageRequest(std::move(session_info),
560 std::move(session_message)); 560 std::move(session_message));
561 } 561 }
562 562
563 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( 563 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus(
564 const GURL& availability_url) 564 const GURL& availability_url)
565 : url(availability_url), 565 : url(availability_url),
566 last_known_availability(false), 566 last_known_availability(false),
567 listening_state(ListeningState::INACTIVE) {} 567 listening_state(ListeningState::INACTIVE) {}
568 568
569 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { 569 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() {
570 } 570 }
571 571
572 } // namespace content 572 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698