OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 WebBlobRegistry_h | 31 #ifndef WebBlobRegistry_h |
32 #define WebBlobRegistry_h | 32 #define WebBlobRegistry_h |
33 | 33 |
34 #include "WebCommon.h" | 34 #include "WebCommon.h" |
| 35 #include "WebThreadSafeData.h" |
35 | 36 |
36 namespace blink { | 37 namespace blink { |
37 | 38 |
38 class WebBlobData; | 39 class WebBlobData; |
39 class WebString; | 40 class WebString; |
40 class WebURL; | 41 class WebURL; |
41 | 42 |
| 43 // Acts as singleton facade for all Blob interactions ouside of blink. This |
| 44 // includes blob: |
| 45 // * creation, |
| 46 // * reference counting, |
| 47 // * publishing, and |
| 48 // * streaming. |
42 class WebBlobRegistry { | 49 class WebBlobRegistry { |
43 public: | 50 public: |
| 51 // Builder class for creating blobs. The blob is built on calling the |
| 52 // build() method, where IPCs are sent to the browser. |
| 53 // Preconditions: |
| 54 // * Not meant to be used on multiple threads. |
| 55 // * Must not be kept alive longer than creator WebBlobRegistry (shouldn't |
| 56 // be an issue because of the singleton nature of the WebBlobRegistry) |
| 57 // * append.* methods are invalid after build() is called. |
| 58 class Builder { |
| 59 public: |
| 60 virtual ~Builder() { } |
| 61 virtual void appendData(const WebThreadSafeData&) = 0; |
| 62 virtual void appendFile(const WebString& path, uint64_t offset, uint64_t
length, double expectedModificationTime) = 0; |
| 63 // Calling this method ensures the given blob lives for the creation of |
| 64 // the new blob. |
| 65 virtual void appendBlob(const WebString& uuid, uint64_t offset, uint64_t
length) = 0; |
| 66 virtual void appendFileSystemURL(const WebURL&, uint64_t offset, uint64_
t length, double expectedModificationTime) = 0; |
| 67 |
| 68 // Builds the blob. All calls to append* are invalid after calling this |
| 69 // method. |
| 70 virtual void build() = 0; |
| 71 }; |
| 72 |
44 virtual ~WebBlobRegistry() { } | 73 virtual ~WebBlobRegistry() { } |
45 | 74 |
| 75 // TODO(dmurph): Deprecate and migrate to createBuilder |
46 virtual void registerBlobData(const WebString& uuid, const WebBlobData&) { } | 76 virtual void registerBlobData(const WebString& uuid, const WebBlobData&) { } |
| 77 |
| 78 // Caller takes ownership of the Builder. The blob is finalized (and sent to |
| 79 // the browser) on calling build() on the Builder object. |
| 80 virtual Builder* createBuilder(const WebString& uuid, const WebString& conte
ntType) { BLINK_ASSERT_NOT_REACHED(); return nullptr; } |
| 81 |
47 virtual void addBlobDataRef(const WebString& uuid) { } | 82 virtual void addBlobDataRef(const WebString& uuid) { } |
48 virtual void removeBlobDataRef(const WebString& uuid) { } | 83 virtual void removeBlobDataRef(const WebString& uuid) { } |
49 virtual void registerPublicBlobURL(const WebURL&, const WebString& uuid) { } | 84 virtual void registerPublicBlobURL(const WebURL&, const WebString& uuid) { } |
50 virtual void revokePublicBlobURL(const WebURL&) { } | 85 virtual void revokePublicBlobURL(const WebURL&) { } |
51 | 86 |
52 // Registers a stream URL referring to a stream with the specified media | 87 // Registers a stream URL referring to a stream with the specified media |
53 // type. | 88 // type. |
54 virtual void registerStreamURL(const WebURL&, const WebString&) { BLINK_ASSE
RT_NOT_REACHED(); } | 89 virtual void registerStreamURL(const WebURL&, const WebString&) { BLINK_ASSE
RT_NOT_REACHED(); } |
55 | 90 |
56 // Registers a stream URL referring to the stream identified by the | 91 // Registers a stream URL referring to the stream identified by the |
(...skipping 14 matching lines...) Expand all Loading... |
71 // so it won't receive any more data. | 106 // so it won't receive any more data. |
72 virtual void abortStream(const WebURL&) { BLINK_ASSERT_NOT_REACHED(); } | 107 virtual void abortStream(const WebURL&) { BLINK_ASSERT_NOT_REACHED(); } |
73 | 108 |
74 // Unregisters a stream referred by the URL. | 109 // Unregisters a stream referred by the URL. |
75 virtual void unregisterStreamURL(const WebURL&) { BLINK_ASSERT_NOT_REACHED()
; } | 110 virtual void unregisterStreamURL(const WebURL&) { BLINK_ASSERT_NOT_REACHED()
; } |
76 }; | 111 }; |
77 | 112 |
78 } // namespace blink | 113 } // namespace blink |
79 | 114 |
80 #endif // WebBlobRegistry_h | 115 #endif // WebBlobRegistry_h |
OLD | NEW |