OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_CHILD_WEBBLOBREGISTRY_IMPL_H_ | 5 #ifndef CONTENT_CHILD_WEBBLOBREGISTRY_IMPL_H_ |
6 #define CONTENT_CHILD_WEBBLOBREGISTRY_IMPL_H_ | 6 #define CONTENT_CHILD_WEBBLOBREGISTRY_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
| 9 #include <vector> |
9 | 10 |
10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
11 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | 12 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 class WebThreadSafeData; | 15 class WebThreadSafeData; |
15 } // namespace blink | 16 } // namespace blink |
16 | 17 |
| 18 namespace storage { |
| 19 class DataElement; |
| 20 } |
| 21 |
17 namespace content { | 22 namespace content { |
18 class ThreadSafeSender; | 23 class ThreadSafeSender; |
19 | 24 |
20 class WebBlobRegistryImpl : public blink::WebBlobRegistry { | 25 class WebBlobRegistryImpl : public blink::WebBlobRegistry { |
21 public: | 26 public: |
22 explicit WebBlobRegistryImpl(ThreadSafeSender* sender); | 27 explicit WebBlobRegistryImpl(ThreadSafeSender* sender); |
23 virtual ~WebBlobRegistryImpl(); | 28 virtual ~WebBlobRegistryImpl(); |
24 | 29 |
25 virtual void registerBlobData(const blink::WebString& uuid, | 30 virtual void registerBlobData(const blink::WebString& uuid, |
26 const blink::WebBlobData& data); | 31 const blink::WebBlobData& data); |
27 virtual void addBlobDataRef(const blink::WebString& uuid); | 32 virtual void addBlobDataRef(const blink::WebString& uuid); |
28 virtual void removeBlobDataRef(const blink::WebString& uuid); | 33 virtual void removeBlobDataRef(const blink::WebString& uuid); |
29 virtual void registerPublicBlobURL(const blink::WebURL&, | 34 virtual void registerPublicBlobURL(const blink::WebURL&, |
30 const blink::WebString& uuid); | 35 const blink::WebString& uuid); |
31 virtual void revokePublicBlobURL(const blink::WebURL&); | 36 virtual void revokePublicBlobURL(const blink::WebURL&); |
32 | 37 |
33 // Additional support for Streams. | 38 // Additional support for Streams. |
34 virtual void registerStreamURL(const blink::WebURL& url, | 39 virtual void registerStreamURL(const blink::WebURL& url, |
35 const blink::WebString& content_type); | 40 const blink::WebString& content_type); |
36 virtual void registerStreamURL(const blink::WebURL& url, | 41 virtual void registerStreamURL(const blink::WebURL& url, |
37 const blink::WebURL& src_url); | 42 const blink::WebURL& src_url); |
38 virtual void addDataToStream(const blink::WebURL& url, | 43 virtual void addDataToStream(const blink::WebURL& url, |
39 const char* data, size_t length); | 44 const char* data, size_t length); |
40 virtual void flushStream(const blink::WebURL& url); | 45 virtual void flushStream(const blink::WebURL& url); |
41 virtual void finalizeStream(const blink::WebURL& url); | 46 virtual void finalizeStream(const blink::WebURL& url); |
42 virtual void abortStream(const blink::WebURL& url); | 47 virtual void abortStream(const blink::WebURL& url); |
43 virtual void unregisterStreamURL(const blink::WebURL& url); | 48 virtual void unregisterStreamURL(const blink::WebURL& url); |
44 | 49 |
45 private: | 50 private: |
46 void SendDataForBlob(const std::string& uuid_str, | 51 // Sends the data in the buffer as a blob item, then resets the buffer size. |
47 const blink::WebThreadSafeData& data); | 52 void FlushBlobItemBuffer(const std::string& uuid_str, |
| 53 storage::DataElement* data_buffer) const; |
| 54 |
| 55 // Adds the item to the consolidating buffer, flushing the buffer if needed. |
| 56 // If the item is too big for the buffer, it is sent as Sync messages in |
| 57 // shared memory instead. |
| 58 void BufferBlobData(const std::string& uuid_str, |
| 59 const blink::WebThreadSafeData& data, |
| 60 storage::DataElement* data_buffer); |
| 61 // Sends data that is larger than the threshold. |
| 62 void SendOversizedDataForBlob(const std::string& uuid_str, |
| 63 const blink::WebThreadSafeData& data); |
48 | 64 |
49 scoped_refptr<ThreadSafeSender> sender_; | 65 scoped_refptr<ThreadSafeSender> sender_; |
50 }; | 66 }; |
51 | 67 |
52 } // namespace content | 68 } // namespace content |
53 | 69 |
54 #endif // CONTENT_CHILD_FILEAPI_WEBBLOBREGISTRY_IMPL_H_ | 70 #endif // CONTENT_CHILD_FILEAPI_WEBBLOBREGISTRY_IMPL_H_ |
OLD | NEW |