Chromium Code Reviews| Index: content/renderer/presentation/presentation_dispatcher.h | 
| diff --git a/content/renderer/presentation/presentation_dispatcher.h b/content/renderer/presentation/presentation_dispatcher.h | 
| index 0099a0f2a048bff297efaa9724fe1d9a3096199b..1dd7c1243550b00d0c90b720c78848c163b5b62e 100644 | 
| --- a/content/renderer/presentation/presentation_dispatcher.h | 
| +++ b/content/renderer/presentation/presentation_dispatcher.h | 
| @@ -6,6 +6,8 @@ | 
| #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ | 
| #include "base/compiler_specific.h" | 
| +#include "base/containers/hash_tables.h" | 
| +#include "base/memory/linked_ptr.h" | 
| #include "base/memory/scoped_vector.h" | 
| #include "content/common/content_export.h" | 
| #include "content/common/presentation/presentation_service.mojom.h" | 
| @@ -29,6 +31,23 @@ class CONTENT_EXPORT PresentationDispatcher | 
| ~PresentationDispatcher() override; | 
| private: | 
| + | 
| + // postMessage request from a presentation session. | 
| + struct CONTENT_EXPORT PostMessageRequest { | 
| + PostMessageRequest(const std::string& presentation_url, | 
| + const std::string& presentation_id, | 
| + const std::string& message); | 
| + ~PostMessageRequest(); | 
| + | 
| + const std::string presentation_url; | 
| + const std::string presentation_id; | 
| + const std::string message; | 
| + | 
| + // Need to handle ArrayBuffer/View and Blob data also | 
| 
 
imcheng
2015/04/02 23:57:24
Please add a TODO here.
 
USE s.singapati at gmail.com
2015/04/07 17:45:16
Done.
 
 | 
| + //presentation::MessageType message_type; | 
| + //presentation::BinaryType binary_type; | 
| + }; | 
| + | 
| // WebPresentationClient implementation. | 
| virtual void setController( | 
| blink::WebPresentationController* controller); | 
| @@ -41,6 +60,15 @@ class CONTENT_EXPORT PresentationDispatcher | 
| const blink::WebString& presentationUrl, | 
| const blink::WebString& presentationId, | 
| blink::WebPresentationSessionClientCallbacks* callback); | 
| + virtual void postMessage( | 
| + const blink::WebString& presentationUrl, | 
| + const blink::WebString& presentationId, | 
| + const blink::WebString& message); | 
| + virtual void postMessage( | 
| + const blink::WebString& presentationUrl, | 
| + const blink::WebString& presentationId, | 
| + const char* data, | 
| + size_t length); | 
| virtual void closeSession( | 
| const blink::WebString& presentationUrl, | 
| const blink::WebString& presentationId); | 
| @@ -64,6 +92,17 @@ class CONTENT_EXPORT PresentationDispatcher | 
| const std::string& presentation_url, | 
| bool watched); | 
| + void PostMessagesOfFirstSession(); | 
| + | 
| + void HandlePostMessageRequests(); | 
| + | 
| + void DoPostMessages( | 
| + const std::string& presentation_url, | 
| + const std::string& presentation_id, | 
| + std::vector<std::string> string_messages); | 
| + | 
| + void RemovePostMessageRequestsOfFirstSession(); | 
| + | 
| // Used as a weak reference. Can be null since lifetime is bound to the frame. | 
| blink::WebPresentationController* controller_; | 
| presentation::PresentationServicePtr presentation_service_; | 
| @@ -75,6 +114,13 @@ class CONTENT_EXPORT PresentationDispatcher | 
| using PresentationSessionDispatchers = | 
| ScopedVector<PresentationSessionDispatcher>; | 
| PresentationSessionDispatchers presentation_session_dispatchers_; | 
| + | 
| + // Map of presentation ID to its postMessage requests. | 
| + typedef std::vector<linked_ptr<PostMessageRequest>> PostMessageVector; | 
| 
 
imcheng
2015/04/02 23:57:24
using PostMessageVector = std::vector<linked_ptr<P
 
USE s.singapati at gmail.com
2015/04/07 17:45:16
Done.
 
 | 
| + typedef base::hash_map<std::string, linked_ptr<PostMessageVector>> | 
| + PostMessageRequestMap; | 
| + | 
| + PostMessageRequestMap post_message_requests_map_; | 
| 
 
imcheng
2015/04/02 23:57:24
If we are sending 1 message per mojo call (I think
 
USE s.singapati at gmail.com
2015/04/07 17:45:16
Acknowledged. Simple queuing approach in new patch
 
 | 
| }; | 
| } // namespace content |