Chromium Code Reviews| Index: public/platform/modules/navigator_services/WebServicePortProvider.h |
| diff --git a/public/platform/modules/navigator_services/WebServicePortProvider.h b/public/platform/modules/navigator_services/WebServicePortProvider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6c1499a67d12891c34641fca80007641f2560906 |
| --- /dev/null |
| +++ b/public/platform/modules/navigator_services/WebServicePortProvider.h |
| @@ -0,0 +1,47 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef WebServicePortProvider_h |
| +#define WebServicePortProvider_h |
| + |
| +#include "public/platform/WebCallbacks.h" |
| +#include "public/platform/WebVector.h" |
| +#include "public/platform/modules/navigator_services/WebServicePort.h" |
| + |
| +namespace blink { |
| + |
| +class WebString; |
| +class WebURL; |
| +typedef WebVector<class WebMessagePortChannel*> WebMessagePortChannelArray; |
| + |
| +typedef WebCallbacks<WebServicePortID, void> WebServicePortConnectCallbacks; |
| + |
| +// One instance of this class is associated with each ServicePortCollection. |
| +// When a ServicePortCollection is destroyed the WebServicePortProvider |
| +// associated with it is also destroyed. All communication from ServicePorts and |
| +// the ServicePortCollection to embedding code goes via this interface. |
| +class WebServicePortProvider { |
| +public: |
| + virtual ~WebServicePortProvider() { } |
| + |
| + // Initiates a connection from the given origin to the given URL. When |
| + // successful the service can communicate with the client over the given |
| + // channel. The origin isn't passed as WebSecurityOrigin because that would |
| + // be a layering violation (platform/ code shouldn't depend on web/ code). |
| + // Ownership of the WebServicePortConnectCallbacks is transferred to the provider. |
| + virtual void connect(const WebURL&, const WebString& origin, WebServicePortConnectCallbacks*) { BLINK_ASSERT_NOT_REACHED(); } |
| + |
| + // Called when javascript code calls postMessage on a ServicePort that is owned |
| + // by the ServicePortCollection this provider is associated with. |
| + virtual void postMessage(WebServicePortID, const WebString&, WebMessagePortChannelArray*) { BLINK_ASSERT_NOT_REACHED(); } |
|
scheib
2015/06/24 04:16:55
I think: // Takes ownership of WebMessagePortChann
|
| + |
| + // Called when a ServicePort owned by the ServicePortCollection this |
| + // provider is associated with is closed (explicitly or via garbage |
| + // collection). |
| + virtual void closePort(WebServicePortID) { BLINK_ASSERT_NOT_REACHED(); } |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // WebServicePortProvider_h |