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

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

Issue 1214083013: Presentation API: implement .getAvailability() (Chromium side). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 #ifndef CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ 5 #ifndef CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ 6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/id_map.h"
9 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
10 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
11 #include "content/common/presentation/presentation_service.mojom.h" 12 #include "content/common/presentation/presentation_service.mojom.h"
12 #include "content/public/renderer/render_frame_observer.h" 13 #include "content/public/renderer/render_frame_observer.h"
13 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nClient.h" 14 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nClient.h"
14 15
15 namespace blink { 16 namespace blink {
17 class WebPresentationAvailabilityObserver;
16 class WebString; 18 class WebString;
17 } // namespace blink 19 } // namespace blink
18 20
19 namespace content { 21 namespace content {
20 22
21 // PresentationDispatcher is a delegate for Presentation API messages used by 23 // PresentationDispatcher is a delegate for Presentation API messages used by
22 // Blink. It forwards the calls to the Mojo PresentationService. 24 // Blink. It forwards the calls to the Mojo PresentationService.
23 class CONTENT_EXPORT PresentationDispatcher 25 class CONTENT_EXPORT PresentationDispatcher
24 : public RenderFrameObserver, 26 : public RenderFrameObserver,
25 public NON_EXPORTED_BASE(blink::WebPresentationClient), 27 public NON_EXPORTED_BASE(blink::WebPresentationClient),
(...skipping 25 matching lines...) Expand all
51 const uint8* data, 53 const uint8* data,
52 size_t length); 54 size_t length);
53 virtual void sendBlobData( 55 virtual void sendBlobData(
54 const blink::WebString& presentationUrl, 56 const blink::WebString& presentationUrl,
55 const blink::WebString& presentationId, 57 const blink::WebString& presentationId,
56 const uint8* data, 58 const uint8* data,
57 size_t length); 59 size_t length);
58 virtual void closeSession( 60 virtual void closeSession(
59 const blink::WebString& presentationUrl, 61 const blink::WebString& presentationUrl,
60 const blink::WebString& presentationId); 62 const blink::WebString& presentationId);
63 virtual void getAvailability(
64 const blink::WebString& presentationUrl,
65 blink::WebPresentationAvailabilityCallbacks* callbacks);
66 virtual void startListening(blink::WebPresentationAvailabilityObserver*);
67 virtual void stopListening(blink::WebPresentationAvailabilityObserver*);
61 68
62 // RenderFrameObserver implementation. 69 // RenderFrameObserver implementation.
63 void DidChangeDefaultPresentation() override; 70 void DidChangeDefaultPresentation() override;
64 void DidCommitProvisionalLoad( 71 void DidCommitProvisionalLoad(
65 bool is_new_navigation, 72 bool is_new_navigation,
66 bool is_same_page_navigation) override; 73 bool is_same_page_navigation) override;
67 74
68 // presentation::PresentationServiceClient 75 // presentation::PresentationServiceClient
69 void OnScreenAvailabilityUpdated(bool available) override; 76 void OnScreenAvailabilityUpdated(bool available) override;
70 77
71 void OnSessionCreated( 78 void OnSessionCreated(
72 blink::WebPresentationSessionClientCallbacks* callback, 79 blink::WebPresentationSessionClientCallbacks* callback,
73 presentation::PresentationSessionInfoPtr session_info, 80 presentation::PresentationSessionInfoPtr session_info,
74 presentation::PresentationErrorPtr error); 81 presentation::PresentationErrorPtr error);
75 void OnDefaultSessionStarted( 82 void OnDefaultSessionStarted(
76 presentation::PresentationSessionInfoPtr session_info); 83 presentation::PresentationSessionInfoPtr session_info);
77 void OnSessionStateChange( 84 void OnSessionStateChange(
78 presentation::PresentationSessionInfoPtr session_info, 85 presentation::PresentationSessionInfoPtr session_info,
79 presentation::PresentationSessionState session_state); 86 presentation::PresentationSessionState session_state);
80 void OnSessionMessagesReceived( 87 void OnSessionMessagesReceived(
81 mojo::Array<presentation::SessionMessagePtr> messages); 88 mojo::Array<presentation::SessionMessagePtr> messages);
82 void DoSendMessage(const presentation::SessionMessage& session_message); 89 void DoSendMessage(const presentation::SessionMessage& session_message);
83 void HandleSendMessageRequests(bool success); 90 void HandleSendMessageRequests(bool success);
84 91
85 void ConnectToPresentationServiceIfNeeded(); 92 void ConnectToPresentationServiceIfNeeded();
86 93
94 void UpdateListeningState();
95
87 // Used as a weak reference. Can be null since lifetime is bound to the frame. 96 // Used as a weak reference. Can be null since lifetime is bound to the frame.
88 blink::WebPresentationController* controller_; 97 blink::WebPresentationController* controller_;
89 presentation::PresentationServicePtr presentation_service_; 98 presentation::PresentationServicePtr presentation_service_;
90 mojo::Binding<presentation::PresentationServiceClient> binding_; 99 mojo::Binding<presentation::PresentationServiceClient> binding_;
91 100
92 // Message requests are queued here and only one message at a time is sent 101 // Message requests are queued here and only one message at a time is sent
93 // over mojo channel. 102 // over mojo channel.
94 using MessageRequestQueue = 103 using MessageRequestQueue =
95 std::queue<linked_ptr<presentation::SessionMessage>>; 104 std::queue<linked_ptr<presentation::SessionMessage>>;
96 MessageRequestQueue message_request_queue_; 105 MessageRequestQueue message_request_queue_;
97 106
107 enum class ListeningState {
108 Inactive,
109 Waiting,
whywhat 2015/07/02 22:42:48 This state is not used, only to assign it to the l
mlamouri (slow - plz ping) 2015/07/03 13:35:46 It is not directly used but indirectly. When getAv
110 Active,
111 };
112
113 ListeningState listening_;
whywhat 2015/07/02 22:42:48 s/listening_/listening_state_
mlamouri (slow - plz ping) 2015/07/03 13:35:46 Done.
114 bool previous_availability_;
whywhat 2015/07/02 22:42:48 nit: previous to what? last_known_availability_ ma
mlamouri (slow - plz ping) 2015/07/03 13:35:46 Done.
115
116 using AvailabilityCallbacksMap =
117 IDMap<blink::WebPresentationAvailabilityCallbacks, IDMapOwnPointer>;
118 AvailabilityCallbacksMap availability_callbacks_;
119
120 using AvailabilityObserversSet =
121 std::set<blink::WebPresentationAvailabilityObserver*>;
122 AvailabilityObserversSet availability_observers_;
123
98 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); 124 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher);
99 }; 125 };
100 126
101 } // namespace content 127 } // namespace content
102 128
103 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ 129 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698