OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef WebMessagePortChannel_h | 31 #ifndef WebMessagePortChannel_h |
32 #define WebMessagePortChannel_h | 32 #define WebMessagePortChannel_h |
33 | 33 |
34 #include "WebCommon.h" | 34 #include "WebCommon.h" |
35 #include "WebVector.h" | 35 #include "WebVector.h" |
36 | 36 |
| 37 #if INSIDE_BLINK |
| 38 #include <memory> |
| 39 #endif |
| 40 |
37 namespace blink { | 41 namespace blink { |
38 | 42 |
39 class WebMessagePortChannelClient; | 43 class WebMessagePortChannelClient; |
40 class WebString; | 44 class WebString; |
41 | 45 |
42 typedef WebVector<class WebMessagePortChannel*> WebMessagePortChannelArray; | 46 typedef WebVector<class WebMessagePortChannel*> WebMessagePortChannelArray; |
43 | 47 |
44 // Provides an interface to a Message Port Channel implementation. The object ow
ns itself and | 48 // Provides an interface to a Message Port Channel implementation. The object ow
ns itself and |
45 // is signalled that its not needed anymore with the destroy() call. | 49 // is signalled that its not needed anymore with the destroy() call. |
46 class WebMessagePortChannel { | 50 class WebMessagePortChannel { |
47 public: | 51 public: |
48 virtual void setClient(WebMessagePortChannelClient*) = 0; | 52 virtual void setClient(WebMessagePortChannelClient*) = 0; |
49 virtual void destroy() = 0; | 53 virtual void destroy() = 0; |
50 // Callee receives ownership of the passed vector. | 54 // Callee receives ownership of the passed vector. |
51 // FIXME: Blob refs should be passed to maintain ref counts. crbug.com/35175
3 | 55 // FIXME: Blob refs should be passed to maintain ref counts. crbug.com/35175
3 |
52 virtual void postMessage(const WebString&, WebMessagePortChannelArray*) = 0; | 56 virtual void postMessage(const WebString&, WebMessagePortChannelArray*) = 0; |
53 virtual bool tryGetMessage(WebString*, WebMessagePortChannelArray&) = 0; | 57 virtual bool tryGetMessage(WebString*, WebMessagePortChannelArray&) = 0; |
54 | 58 |
55 protected: | 59 protected: |
56 ~WebMessagePortChannel() { } | 60 ~WebMessagePortChannel() { } |
57 }; | 61 }; |
58 | 62 |
59 } // namespace blink | |
60 | |
61 #if INSIDE_BLINK | 63 #if INSIDE_BLINK |
62 | 64 |
63 namespace WTF { | 65 struct WebMessagePortChannelDeleter { |
64 | 66 void operator()(WebMessagePortChannel* channel) |
65 template<typename T> struct OwnedPtrDeleter; | |
66 template<> struct OwnedPtrDeleter<blink::WebMessagePortChannel> { | |
67 static void deletePtr(blink::WebMessagePortChannel* channel) | |
68 { | 67 { |
69 if (channel) | 68 if (channel) |
70 channel->destroy(); | 69 channel->destroy(); |
71 } | 70 } |
72 }; | 71 }; |
73 | 72 |
74 } // namespace WTF | 73 using WebMessagePortChannelUniquePtr = std::unique_ptr<WebMessagePortChannel, We
bMessagePortChannelDeleter>; |
75 | 74 |
76 #endif // INSIDE_BLINK | 75 #endif // INSIDE_BLINK |
77 | 76 |
| 77 } // namespace blink |
| 78 |
78 #endif // WebMessagePortChannel_h | 79 #endif // WebMessagePortChannel_h |
OLD | NEW |