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