Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: content/child/webblobregistry_impl.h

Issue 1234813004: [BlobAsync] Asynchronous Blob Construction Final Patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blob-protocol-change
Patch Set: added shared memory test, and fixed memory leak Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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(base::SingleThreadTaskRunner* io_runner,
34 ThreadSafeSender* sender);
33 ~WebBlobRegistryImpl() override; 35 ~WebBlobRegistryImpl() override;
34 36
35 // TODO(dmurph): remove this after moving to createBuilder. crbug.com/504583 37 // TODO(dmurph): remove this after moving to createBuilder. crbug.com/504583
36 void registerBlobData(const blink::WebString& uuid, 38 void registerBlobData(const blink::WebString& uuid,
37 const blink::WebBlobData& data) override; 39 const blink::WebBlobData& data) override;
38 40
39 blink::WebBlobRegistry::Builder* createBuilder( 41 blink::WebBlobRegistry::Builder* createBuilder(
40 const blink::WebString& uuid, 42 const blink::WebString& uuid,
41 const blink::WebString& content_type) override; 43 const blink::WebString& content_type) override;
42 44
(...skipping 14 matching lines...) Expand all
57 void flushStream(const blink::WebURL& url) override; 59 void flushStream(const blink::WebURL& url) override;
58 void finalizeStream(const blink::WebURL& url) override; 60 void finalizeStream(const blink::WebURL& url) override;
59 void abortStream(const blink::WebURL& url) override; 61 void abortStream(const blink::WebURL& url) override;
60 void unregisterStreamURL(const blink::WebURL& url) override; 62 void unregisterStreamURL(const blink::WebURL& url) override;
61 63
62 private: 64 private:
63 // Handles all of the IPCs sent for building a blob. 65 // Handles all of the IPCs sent for building a blob.
64 class BuilderImpl : public blink::WebBlobRegistry::Builder { 66 class BuilderImpl : public blink::WebBlobRegistry::Builder {
65 public: 67 public:
66 BuilderImpl(const blink::WebString& uuid, 68 BuilderImpl(const blink::WebString& uuid,
67 const blink::WebString& contentType, 69 const blink::WebString& content_type,
68 ThreadSafeSender* sender); 70 ThreadSafeSender* sender,
71 base::SingleThreadTaskRunner* io_runner);
69 ~BuilderImpl() override; 72 ~BuilderImpl() override;
70 73
71 void appendData(const blink::WebThreadSafeData&) override; 74 void appendData(const blink::WebThreadSafeData&) override;
72 void appendFile(const blink::WebString& path, 75 void appendFile(const blink::WebString& path,
73 uint64_t offset, 76 uint64_t offset,
74 uint64_t length, 77 uint64_t length,
75 double expected_modification_time) override; 78 double expected_modification_time) override;
76 void appendBlob(const blink::WebString& uuid, 79 void appendBlob(const blink::WebString& uuid,
77 uint64_t offset, 80 uint64_t offset,
78 uint64_t length) override; 81 uint64_t length) override;
79 void appendFileSystemURL(const blink::WebURL&, 82 void appendFileSystemURL(const blink::WebURL&,
80 uint64_t offset, 83 uint64_t offset,
81 uint64_t length, 84 uint64_t length,
82 double expected_modification_time) override; 85 double expected_modification_time) override;
83 86
84 void build() override; 87 void build() override;
85 88
86 private: 89 private:
87 // Sends data that is larger than the threshold.
88 void SendOversizedDataForBlob(size_t consolidated_item_index);
89
90 const std::string uuid_; 90 const std::string uuid_;
91 const std::string content_type_; 91 const std::string content_type_;
92 BlobConsolidation consolidation_; 92 scoped_ptr<BlobConsolidation> consolidation_;
93 scoped_refptr<ThreadSafeSender> sender_; 93 scoped_refptr<ThreadSafeSender> sender_;
94 scoped_refptr<base::SingleThreadTaskRunner> io_runner_;
94 }; 95 };
95 96
97 // Method called on the IO thread.
98 static void StartBlobAsyncConstruction(
99 const std::string& uuid,
100 scoped_ptr<BlobConsolidation> consolidation,
101 const scoped_refptr<ThreadSafeSender>& sender);
102
103 scoped_refptr<base::SingleThreadTaskRunner> io_runner_;
96 scoped_refptr<ThreadSafeSender> sender_; 104 scoped_refptr<ThreadSafeSender> sender_;
97 }; 105 };
98 106
99 } // namespace content 107 } // namespace content
100 108
101 #endif // CONTENT_CHILD_WEBBLOBREGISTRY_IMPL_H_ 109 #endif // CONTENT_CHILD_BLOB_STORAGE_WEBBLOBREGISTRY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698