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

Side by Side Diff: content/public/browser/presentation_service_delegate.h

Issue 1259073004: [Presentation API] Change ListenForSessionMessages API to client-style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile fix Created 5 years, 4 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_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_
6 #define CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ 6 #define CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "content/public/browser/presentation_session.h" 14 #include "content/public/browser/presentation_session.h"
15 #include "content/public/browser/presentation_session_message.h" 15 #include "content/public/browser/presentation_session_message.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 class PresentationScreenAvailabilityListener; 19 class PresentationScreenAvailabilityListener;
20 20
21 using SessionStateChangedCallback = 21 using SessionStateChangedCallback =
22 base::Callback<void(const PresentationSessionInfo&, 22 base::Callback<void(const PresentationSessionInfo&,
23 PresentationSessionState)>; 23 PresentationSessionState)>;
24 using PresentationSessionMessageCallback = base::Callback<void(
25 const ScopedVector<content::PresentationSessionMessage>&)>;
24 26
25 // An interface implemented by embedders to handle presentation API calls 27 // An interface implemented by embedders to handle presentation API calls
26 // forwarded from PresentationServiceImpl. 28 // forwarded from PresentationServiceImpl.
27 class CONTENT_EXPORT PresentationServiceDelegate { 29 class CONTENT_EXPORT PresentationServiceDelegate {
28 public: 30 public:
29 // Observer interface to listen for changes to PresentationServiceDelegate. 31 // Observer interface to listen for changes to PresentationServiceDelegate.
30 class CONTENT_EXPORT Observer { 32 class CONTENT_EXPORT Observer {
31 public: 33 public:
32 // Called when the PresentationServiceDelegate is being destroyed. 34 // Called when the PresentationServiceDelegate is being destroyed.
33 virtual void OnDelegateDestroyed() = 0; 35 virtual void OnDelegateDestroyed() = 0;
34 36
35 // Called when the default presentation has been started outside of a 37 // Called when the default presentation has been started outside of a
36 // Presentation API context (e.g., browser action). This will not be called 38 // Presentation API context (e.g., browser action). This will not be called
37 // if the session was created as a result of Presentation API's 39 // if the session was created as a result of Presentation API's
38 // StartSession()/JoinSession(). 40 // StartSession()/JoinSession().
39 virtual void OnDefaultPresentationStarted( 41 virtual void OnDefaultPresentationStarted(
40 const PresentationSessionInfo& session) = 0; 42 const PresentationSessionInfo& session) = 0;
41 43
42 protected: 44 protected:
43 virtual ~Observer() {} 45 virtual ~Observer() {}
44 }; 46 };
45 47
46 using PresentationSessionSuccessCallback = 48 using PresentationSessionSuccessCallback =
47 base::Callback<void(const PresentationSessionInfo&)>; 49 base::Callback<void(const PresentationSessionInfo&)>;
48 using PresentationSessionErrorCallback = 50 using PresentationSessionErrorCallback =
49 base::Callback<void(const PresentationError&)>; 51 base::Callback<void(const PresentationError&)>;
50 using PresentationSessionMessageCallback = base::Callback<void(
51 scoped_ptr<ScopedVector<PresentationSessionMessage>>)>;
52 using SendMessageCallback = base::Callback<void(bool)>; 52 using SendMessageCallback = base::Callback<void(bool)>;
53 53
54 virtual ~PresentationServiceDelegate() {} 54 virtual ~PresentationServiceDelegate() {}
55 55
56 // Registers an observer associated with frame with |render_process_id| 56 // Registers an observer associated with frame with |render_process_id|
57 // and |render_frame_id| with this class to listen for updates. 57 // and |render_frame_id| with this class to listen for updates.
58 // This class does not own the observer. 58 // This class does not own the observer.
59 // It is an error to add an observer if there is already an observer for that 59 // It is an error to add an observer if there is already an observer for that
60 // frame. 60 // frame.
61 virtual void AddObserver(int render_process_id, 61 virtual void AddObserver(int render_process_id,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 const PresentationSessionSuccessCallback& success_cb, 137 const PresentationSessionSuccessCallback& success_cb,
138 const PresentationSessionErrorCallback& error_cb) = 0; 138 const PresentationSessionErrorCallback& error_cb) = 0;
139 139
140 // Close an existing presentation session. 140 // Close an existing presentation session.
141 // |render_process_id|, |render_frame_id|: ID for originating frame. 141 // |render_process_id|, |render_frame_id|: ID for originating frame.
142 // |presentation_id|: The ID of the presentation to close. 142 // |presentation_id|: The ID of the presentation to close.
143 virtual void CloseSession(int render_process_id, 143 virtual void CloseSession(int render_process_id,
144 int render_frame_id, 144 int render_frame_id,
145 const std::string& presentation_id) = 0; 145 const std::string& presentation_id) = 0;
146 146
147 // Gets the next batch of messages from all presentation sessions in the frame 147 // Listen for messages for a presentation session.
148 // |render_process_id|, |render_frame_id|: ID for originating frame. 148 // |render_process_id|, |render_frame_id|: ID for originating frame.
149 // |message_cb|: Invoked with a non-empty list of messages. 149 // |session|: URL and ID of presentation session to listen for messages.
150 // |message_cb|: Invoked with a non-empty list of messages whenever there are
151 // messages.
150 virtual void ListenForSessionMessages( 152 virtual void ListenForSessionMessages(
151 int render_process_id, 153 int render_process_id,
152 int render_frame_id, 154 int render_frame_id,
155 const content::PresentationSessionInfo& session,
153 const PresentationSessionMessageCallback& message_cb) = 0; 156 const PresentationSessionMessageCallback& message_cb) = 0;
154 157
155 // Sends a message (string or binary data) to a presentation session. 158 // Sends a message (string or binary data) to a presentation session.
156 // |render_process_id|, |render_frame_id|: ID of originating frame. 159 // |render_process_id|, |render_frame_id|: ID of originating frame.
157 // |message_request|: Contains Presentation URL, ID and message to be sent 160 // |session|: The presentation session to send the message to.
158 // and delegate is responsible for deallocating the message_request. 161 // |message|: The message to send. The embedder takes ownership of |message|.
162 // Must not be null.
159 // |send_message_cb|: Invoked after handling the send message request. 163 // |send_message_cb|: Invoked after handling the send message request.
160 virtual void SendMessage( 164 virtual void SendMessage(int render_process_id,
161 int render_process_id, 165 int render_frame_id,
162 int render_frame_id, 166 const content::PresentationSessionInfo& session,
163 scoped_ptr<PresentationSessionMessage> message_request, 167 scoped_ptr<PresentationSessionMessage> message,
164 const SendMessageCallback& send_message_cb) = 0; 168 const SendMessageCallback& send_message_cb) = 0;
165 169
166 // Continuously listen for presentation session state changes for a frame. 170 // Continuously listen for presentation session state changes for a frame.
167 // |render_process_id|, |render_frame_id|: ID of frame. 171 // |render_process_id|, |render_frame_id|: ID of frame.
168 // |state_changed_cb|: Invoked with the session and its new state whenever 172 // |state_changed_cb|: Invoked with the session and its new state whenever
169 // there is a state change. 173 // there is a state change.
170 virtual void ListenForSessionStateChange( 174 virtual void ListenForSessionStateChange(
171 int render_process_id, 175 int render_process_id,
172 int render_frame_id, 176 int render_frame_id,
173 const SessionStateChangedCallback& state_changed_cb) = 0; 177 const SessionStateChangedCallback& state_changed_cb) = 0;
174 }; 178 };
175 179
176 } // namespace content 180 } // namespace content
177 181
178 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ 182 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698