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

Side by Side Diff: public/platform/modules/navigator_services/WebServicePortProvider.h

Issue 1191393003: Update client side navigator.connect API to use ServicePortCollection [1/3] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@serviceport
Patch Set: improve comments Created 5 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WebServicePortProvider_h
6 #define WebServicePortProvider_h
7
8 #include "public/platform/WebCallbacks.h"
9 #include "public/platform/WebVector.h"
10 #include "public/platform/modules/navigator_services/WebServicePort.h"
11
12 namespace blink {
13
14 class WebString;
15 class WebURL;
16 typedef WebVector<class WebMessagePortChannel*> WebMessagePortChannelArray;
tkent 2015/06/25 00:07:57 typdef -> using
17
18 typedef WebCallbacks<WebServicePortID, void> WebServicePortConnectCallbacks;
tkent 2015/06/25 00:07:57 typedef -> using
Marijn Kruisselbrink 2015/06/25 01:07:26 Done
19
20 // One instance of this class is associated with each ServicePortCollection.
21 // When a ServicePortCollection is destroyed the WebServicePortProvider
22 // associated with it is also destroyed. All communication from ServicePorts and
23 // the ServicePortCollection to embedding code goes via this interface.
24 class WebServicePortProvider {
25 public:
26 virtual void destroy() { BLINK_ASSERT_NOT_REACHED(); }
27
28 // Initiates a connection from the given origin to the given URL. When
29 // successful the service can communicate with the client over the given
30 // channel. The origin isn't passed as WebSecurityOrigin because that would
31 // be a layering violation (platform/ code shouldn't depend on web/ code).
32 // Ownership of the WebServicePortConnectCallbacks is transferred to the pro vider.
33 virtual void connect(const WebURL&, const WebString& origin, WebServicePortC onnectCallbacks*) { BLINK_ASSERT_NOT_REACHED(); }
34
35 // Called when javascript code calls postMessage on a ServicePort that is ow ned
36 // by the ServicePortCollection this provider is associated with.
37 // Passes ownership of WebMessagePortChannelArray.
38 virtual void postMessage(WebServicePortID, const WebString&, WebMessagePortC hannelArray*) { BLINK_ASSERT_NOT_REACHED(); }
39
40 // Called when a ServicePort owned by the ServicePortCollection this
41 // provider is associated with is closed (explicitly or via garbage
42 // collection).
43 virtual void closePort(WebServicePortID) { BLINK_ASSERT_NOT_REACHED(); }
44 protected:
tkent 2015/06/25 00:07:57 add a blank line before protected:
Marijn Kruisselbrink 2015/06/25 01:07:26 Done
45 virtual ~WebServicePortProvider() { }
tkent 2015/06/25 00:07:57 nit: now we allow to omit a space between { and }.
Marijn Kruisselbrink 2015/06/25 01:07:26 Done
46 };
47
48 } // namespace blink
49
50 #if INSIDE_BLINK
51
52 namespace WTF {
53
54 template<typename T> struct OwnedPtrDeleter;
55 template<> struct OwnedPtrDeleter<blink::WebServicePortProvider> {
56 static void deletePtr(blink::WebServicePortProvider* provider)
57 {
58 if (provider)
59 provider->destroy();
60 }
61 };
62
63 } // namespace WTF
64
65 #endif // INSIDE_BLINK
66
67 #endif // WebServicePortProvider_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698