Chromium Code Reviews| 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 25 matching lines...) Expand all Loading... | |
| 36 | 36 |
| 37 #if INSIDE_BLINK | 37 #if INSIDE_BLINK |
| 38 #include <memory> | 38 #include <memory> |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 class WebMessagePortChannelClient; | 43 class WebMessagePortChannelClient; |
| 44 class WebString; | 44 class WebString; |
| 45 | 45 |
| 46 typedef WebVector<class WebMessagePortChannel*> WebMessagePortChannelArray; | 46 typedef WebVector<class WebMessagePortChannel*> WebMessagePortChannelArray; |
|
kinuko
2017/01/24 12:32:55
Should this probably be a vector of std::unique_pt
darin (slow to review)
2017/01/26 22:20:03
Great idea
| |
| 47 | 47 |
| 48 // Provides an interface to a Message Port Channel implementation. The object | 48 // Provides an interface to a Message Port Channel implementation. The object |
| 49 // owns itself and is signalled that its not needed anymore with the destroy() | 49 // owns itself and is signalled that its not needed anymore with the destroy() |
| 50 // call. | 50 // call. |
|
kinuko
2017/01/24 12:32:55
This comment is stale now?
darin (slow to review)
2017/01/26 22:20:03
Yes, thanks
| |
| 51 class WebMessagePortChannel { | 51 class WebMessagePortChannel { |
| 52 public: | 52 public: |
| 53 virtual ~WebMessagePortChannel() {} | |
| 53 virtual void setClient(WebMessagePortChannelClient*) = 0; | 54 virtual void setClient(WebMessagePortChannelClient*) = 0; |
| 54 virtual void destroy() = 0; | |
| 55 // Callee receives ownership of the passed vector. | 55 // Callee receives ownership of the passed vector. |
| 56 // FIXME: Blob refs should be passed to maintain ref counts. crbug.com/351753 | 56 // FIXME: Blob refs should be passed to maintain ref counts. crbug.com/351753 |
| 57 virtual void postMessage(const WebString&, WebMessagePortChannelArray*) = 0; | 57 virtual void postMessage(const WebString&, WebMessagePortChannelArray*) = 0; |
| 58 virtual bool tryGetMessage(WebString*, WebMessagePortChannelArray&) = 0; | 58 virtual bool tryGetMessage(WebString*, WebMessagePortChannelArray&) = 0; |
| 59 | |
| 60 protected: | |
| 61 ~WebMessagePortChannel() {} | |
| 62 }; | 59 }; |
| 63 | 60 |
| 64 #if INSIDE_BLINK | 61 #if INSIDE_BLINK |
| 65 | 62 |
| 66 struct WebMessagePortChannelDeleter { | 63 using WebMessagePortChannelUniquePtr = std::unique_ptr<WebMessagePortChannel>; |
| 67 void operator()(WebMessagePortChannel* channel) { | |
| 68 if (channel) | |
| 69 channel->destroy(); | |
| 70 } | |
| 71 }; | |
| 72 | |
| 73 using WebMessagePortChannelUniquePtr = | |
| 74 std::unique_ptr<WebMessagePortChannel, WebMessagePortChannelDeleter>; | |
| 75 | 64 |
| 76 #endif // INSIDE_BLINK | 65 #endif // INSIDE_BLINK |
| 77 | 66 |
| 78 } // namespace blink | 67 } // namespace blink |
| 79 | 68 |
| 80 #endif // WebMessagePortChannel_h | 69 #endif // WebMessagePortChannel_h |
| OLD | NEW |