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_BLOB_STORAGE_WEBBLOBREGISTRY_IMPL_H_ |
6 #define CONTENT_CHILD_WEBBLOBREGISTRY_IMPL_H_ | 6 #define CONTENT_CHILD_BLOB_STORAGE_WEBBLOBREGISTRY_IMPL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "content/child/blob_storage/blob_consolidation.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "storage/common/data_element.h" | 16 #include "storage/common/data_element.h" |
17 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | 17 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" |
18 | 18 |
19 namespace blink { | 19 namespace blink { |
20 class WebThreadSafeData; | 20 class WebThreadSafeData; |
21 } // namespace blink | 21 } // namespace blink |
22 | 22 |
23 namespace storage { | 23 namespace storage { |
24 class DataElement; | 24 class DataElement; |
25 } | 25 } |
26 | 26 |
27 namespace content { | 27 namespace content { |
| 28 class BlobConsolidation; |
28 class ThreadSafeSender; | 29 class ThreadSafeSender; |
29 | 30 |
30 class WebBlobRegistryImpl : public blink::WebBlobRegistry { | 31 class WebBlobRegistryImpl : public blink::WebBlobRegistry { |
31 public: | 32 public: |
32 explicit WebBlobRegistryImpl(ThreadSafeSender* sender); | 33 WebBlobRegistryImpl(scoped_refptr<base::SingleThreadTaskRunner> io_runner, |
| 34 scoped_refptr<base::SingleThreadTaskRunner> main_runner, |
| 35 scoped_refptr<ThreadSafeSender> sender); |
33 ~WebBlobRegistryImpl() override; | 36 ~WebBlobRegistryImpl() override; |
34 | 37 |
35 // TODO(dmurph): remove this after moving to createBuilder. crbug.com/504583 | 38 // TODO(dmurph): remove this after moving to createBuilder. crbug.com/504583 |
36 void registerBlobData(const blink::WebString& uuid, | 39 void registerBlobData(const blink::WebString& uuid, |
37 const blink::WebBlobData& data) override; | 40 const blink::WebBlobData& data) override; |
38 | 41 |
39 blink::WebBlobRegistry::Builder* createBuilder( | 42 blink::WebBlobRegistry::Builder* createBuilder( |
40 const blink::WebString& uuid, | 43 const blink::WebString& uuid, |
41 const blink::WebString& content_type) override; | 44 const blink::WebString& content_type) override; |
42 | 45 |
(...skipping 14 matching lines...) Expand all Loading... |
57 void flushStream(const blink::WebURL& url) override; | 60 void flushStream(const blink::WebURL& url) override; |
58 void finalizeStream(const blink::WebURL& url) override; | 61 void finalizeStream(const blink::WebURL& url) override; |
59 void abortStream(const blink::WebURL& url) override; | 62 void abortStream(const blink::WebURL& url) override; |
60 void unregisterStreamURL(const blink::WebURL& url) override; | 63 void unregisterStreamURL(const blink::WebURL& url) override; |
61 | 64 |
62 private: | 65 private: |
63 // Handles all of the IPCs sent for building a blob. | 66 // Handles all of the IPCs sent for building a blob. |
64 class BuilderImpl : public blink::WebBlobRegistry::Builder { | 67 class BuilderImpl : public blink::WebBlobRegistry::Builder { |
65 public: | 68 public: |
66 BuilderImpl(const blink::WebString& uuid, | 69 BuilderImpl(const blink::WebString& uuid, |
67 const blink::WebString& contentType, | 70 const blink::WebString& content_type, |
68 ThreadSafeSender* sender); | 71 ThreadSafeSender* sender, |
| 72 scoped_refptr<base::SingleThreadTaskRunner> io_runner, |
| 73 scoped_refptr<base::SingleThreadTaskRunner> main_runner); |
69 ~BuilderImpl() override; | 74 ~BuilderImpl() override; |
70 | 75 |
71 void appendData(const blink::WebThreadSafeData&) override; | 76 void appendData(const blink::WebThreadSafeData&) override; |
72 void appendFile(const blink::WebString& path, | 77 void appendFile(const blink::WebString& path, |
73 uint64_t offset, | 78 uint64_t offset, |
74 uint64_t length, | 79 uint64_t length, |
75 double expected_modification_time) override; | 80 double expected_modification_time) override; |
76 void appendBlob(const blink::WebString& uuid, | 81 void appendBlob(const blink::WebString& uuid, |
77 uint64_t offset, | 82 uint64_t offset, |
78 uint64_t length) override; | 83 uint64_t length) override; |
79 void appendFileSystemURL(const blink::WebURL&, | 84 void appendFileSystemURL(const blink::WebURL&, |
80 uint64_t offset, | 85 uint64_t offset, |
81 uint64_t length, | 86 uint64_t length, |
82 double expected_modification_time) override; | 87 double expected_modification_time) override; |
83 | 88 |
84 void build() override; | 89 void build() override; |
85 | 90 |
86 private: | 91 private: |
87 // Sends data that is larger than the threshold. | |
88 void SendOversizedDataForBlob(size_t consolidated_item_index); | |
89 | |
90 const std::string uuid_; | 92 const std::string uuid_; |
91 const std::string content_type_; | 93 const std::string content_type_; |
92 BlobConsolidation consolidation_; | 94 scoped_ptr<BlobConsolidation> consolidation_; |
93 scoped_refptr<ThreadSafeSender> sender_; | 95 scoped_refptr<ThreadSafeSender> sender_; |
| 96 scoped_refptr<base::SingleThreadTaskRunner> io_runner_; |
| 97 scoped_refptr<base::SingleThreadTaskRunner> main_runner_; |
94 }; | 98 }; |
95 | 99 |
| 100 // Method called on the IO thread. |
| 101 static void StartBlobAsyncConstruction( |
| 102 const std::string& uuid, |
| 103 scoped_ptr<BlobConsolidation> consolidation, |
| 104 scoped_refptr<ThreadSafeSender> sender, |
| 105 scoped_refptr<base::SingleThreadTaskRunner> main_runner); |
| 106 |
| 107 scoped_refptr<base::SingleThreadTaskRunner> io_runner_; |
| 108 scoped_refptr<base::SingleThreadTaskRunner> main_runner_; |
96 scoped_refptr<ThreadSafeSender> sender_; | 109 scoped_refptr<ThreadSafeSender> sender_; |
97 }; | 110 }; |
98 | 111 |
99 } // namespace content | 112 } // namespace content |
100 | 113 |
101 #endif // CONTENT_CHILD_WEBBLOBREGISTRY_IMPL_H_ | 114 #endif // CONTENT_CHILD_BLOB_STORAGE_WEBBLOBREGISTRY_IMPL_H_ |
OLD | NEW |