OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_CHILD_BLOB_STORAGE_WEBBLOBREGISTRY_IMPL_H_ | |
6 #define CONTENT_CHILD_BLOB_STORAGE_WEBBLOBREGISTRY_IMPL_H_ | |
7 | |
8 #include <stddef.h> | |
9 #include <stdint.h> | |
10 | |
11 #include <memory> | |
12 #include <string> | |
13 #include <vector> | |
14 | |
15 #include "base/memory/ref_counted.h" | |
16 #include "base/single_thread_task_runner.h" | |
17 #include "storage/common/data_element.h" | |
18 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | |
19 | |
20 namespace blink { | |
21 class WebThreadSafeData; | |
22 } // namespace blink | |
23 | |
24 namespace storage { | |
25 class DataElement; | |
26 } | |
27 | |
28 namespace content { | |
29 class BlobConsolidation; | |
30 class ThreadSafeSender; | |
31 | |
32 class WebBlobRegistryImpl : public blink::WebBlobRegistry { | |
33 public: | |
34 WebBlobRegistryImpl(scoped_refptr<base::SingleThreadTaskRunner> io_runner, | |
35 scoped_refptr<base::SingleThreadTaskRunner> main_runner, | |
36 scoped_refptr<ThreadSafeSender> sender); | |
37 ~WebBlobRegistryImpl() override; | |
38 | |
39 // TODO(dmurph): remove this after moving to createBuilder. crbug.com/504583 | |
40 void registerBlobData(const blink::WebString& uuid, | |
41 const blink::WebBlobData& data) override; | |
42 | |
43 std::unique_ptr<blink::WebBlobRegistry::Builder> createBuilder( | |
44 const blink::WebString& uuid, | |
45 const blink::WebString& content_type) override; | |
46 | |
47 void addBlobDataRef(const blink::WebString& uuid) override; | |
48 void removeBlobDataRef(const blink::WebString& uuid) override; | |
49 void registerPublicBlobURL(const blink::WebURL&, | |
50 const blink::WebString& uuid) override; | |
51 void revokePublicBlobURL(const blink::WebURL&) override; | |
52 | |
53 // Additional support for Streams. | |
54 void registerStreamURL(const blink::WebURL& url, | |
55 const blink::WebString& content_type) override; | |
56 void registerStreamURL(const blink::WebURL& url, | |
57 const blink::WebURL& src_url) override; | |
58 void addDataToStream(const blink::WebURL& url, | |
59 const char* data, | |
60 size_t length) override; | |
61 void flushStream(const blink::WebURL& url) override; | |
62 void finalizeStream(const blink::WebURL& url) override; | |
63 void abortStream(const blink::WebURL& url) override; | |
64 void unregisterStreamURL(const blink::WebURL& url) override; | |
65 | |
66 private: | |
67 // Handles all of the IPCs sent for building a blob. | |
68 class BuilderImpl : public blink::WebBlobRegistry::Builder { | |
69 public: | |
70 BuilderImpl(const blink::WebString& uuid, | |
71 const blink::WebString& content_type, | |
72 ThreadSafeSender* sender, | |
73 scoped_refptr<base::SingleThreadTaskRunner> io_runner, | |
74 scoped_refptr<base::SingleThreadTaskRunner> main_runner); | |
75 ~BuilderImpl() override; | |
76 | |
77 void appendData(const blink::WebThreadSafeData&) override; | |
78 void appendFile(const blink::WebString& path, | |
79 uint64_t offset, | |
80 uint64_t length, | |
81 double expected_modification_time) override; | |
82 void appendBlob(const blink::WebString& uuid, | |
83 uint64_t offset, | |
84 uint64_t length) override; | |
85 void appendFileSystemURL(const blink::WebURL&, | |
86 uint64_t offset, | |
87 uint64_t length, | |
88 double expected_modification_time) override; | |
89 | |
90 void build() override; | |
91 | |
92 private: | |
93 const std::string uuid_; | |
94 const std::string content_type_; | |
95 std::unique_ptr<BlobConsolidation> consolidation_; | |
96 scoped_refptr<ThreadSafeSender> sender_; | |
97 scoped_refptr<base::SingleThreadTaskRunner> io_runner_; | |
98 scoped_refptr<base::SingleThreadTaskRunner> main_runner_; | |
99 }; | |
100 | |
101 scoped_refptr<base::SingleThreadTaskRunner> io_runner_; | |
102 scoped_refptr<base::SingleThreadTaskRunner> main_runner_; | |
103 scoped_refptr<ThreadSafeSender> sender_; | |
104 }; | |
105 | |
106 } // namespace content | |
107 | |
108 #endif // CONTENT_CHILD_BLOB_STORAGE_WEBBLOBREGISTRY_IMPL_H_ | |
OLD | NEW |