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

Side by Side Diff: content/child/blob_storage/blob_transport_controller.h

Issue 1292523002: [BlobAsync] Patch 3: Renderer Classes & Logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async2
Patch Set: comments & cleanup Created 5 years, 1 month 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
(Empty)
1 // Copyright 2015 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_BLOB_TRANSPORT_CONTROLLER_H_
6 #define CONTENT_CHILD_BLOB_STORAGE_BLOB_TRANSPORT_CONTROLLER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/containers/scoped_ptr_map.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/shared_memory_handle.h"
17 #include "content/common/content_export.h"
18 #include "ipc/ipc_platform_file.h"
19 #include "storage/common/blob_storage/blob_storage_constants.h"
20
21 namespace base {
22 template <typename T>
23 struct DefaultLazyInstanceTraits;
24 }
25
26 namespace storage {
27 class DataElement;
28 struct BlobItemBytesRequest;
29 struct BlobItemBytesResponse;
30 }
31
32 namespace IPC {
33 class Sender;
34 }
35
36 namespace content {
37
38 class BlobConsolidation;
39
40 // This class is used to manage all the asynchronous transporation of blobs from
41 // the Renderer to the Browser process, where it's handling the Renderer side.
42 // The function of this class is to:
43 // * Be a lazy singleton,
44 // * hold all of the blob data that is being transported to the Browser process,
45 // * create the blob item 'descriptions' for the browser,
46 // * include shortcut data in the descriptions,
47 // * generate responses to blob memory requests, and
48 // * send IPC responses.
49 // Must be used on the IO thread.
50 class CONTENT_EXPORT BlobTransportController {
51 public:
52 static BlobTransportController* GetInstance();
53
54 // This kicks off a blob transfer to the browser thread, which involves
55 // sending an IPC message and storing the blob consolidation object.
56 void InitiateBlobTransfer(const std::string& uuid,
57 const std::string& type,
58 scoped_ptr<BlobConsolidation> consolidation,
59 IPC::Sender* sender);
60
61 // This responds to the request using the sender.
62 void OnMemoryRequest(
63 const std::string& uuid,
64 const std::vector<storage::BlobItemBytesRequest>& requests,
65 std::vector<base::SharedMemoryHandle>* memory_handles,
66 const std::vector<IPC::PlatformFileForTransit>& file_handles,
67 IPC::Sender* sender);
68
69 void OnCancel(const std::string& uuid,
70 storage::IPCBlobCreationCancelCode code);
71
72 void OnDone(const std::string& uuid);
73
74 // Clears all internal state for testing and such.
75 void Clear();
76
77 ~BlobTransportController();
78
79 private:
80 FRIEND_TEST_ALL_PREFIXES(BlobTransportControllerTest, Descriptions);
81 FRIEND_TEST_ALL_PREFIXES(BlobTransportControllerTest, Responses);
82 FRIEND_TEST_ALL_PREFIXES(BlobTransportControllerTest, SharedMemory);
83 FRIEND_TEST_ALL_PREFIXES(BlobTransportControllerTest, ResponsesErrors);
84
85 enum class ResponsesStatus {
86 BLOB_NOT_FOUND,
87 SHARED_MEMORY_MAP_FAILED,
88 SUCCESS
89 };
90 friend struct base::DefaultLazyInstanceTraits<BlobTransportController>;
91
92 BlobTransportController();
93
94 // Sends the IPC to cancel the blob transfer, and releases the blob from
95 // internal storage.
96 void CancelBlobTransfer(const std::string& uuid,
97 storage::IPCBlobCreationCancelCode code,
98 IPC::Sender* sender);
99
100 void GetDescriptions(BlobConsolidation* consolidation,
101 size_t max_data_population,
102 std::vector<storage::DataElement>* out);
103
104 ResponsesStatus GetResponses(
105 const std::string& uuid,
106 const std::vector<storage::BlobItemBytesRequest>& requests,
107 std::vector<base::SharedMemoryHandle>* memory_handles,
108 const std::vector<IPC::PlatformFileForTransit>& file_handles,
109 std::vector<storage::BlobItemBytesResponse>* output);
110
111 void ReleaseBlobConsolidation(const std::string& uuid);
112
113 base::ScopedPtrMap<std::string, scoped_ptr<BlobConsolidation>> blob_storage_;
114
115 DISALLOW_COPY_AND_ASSIGN(BlobTransportController);
116 };
117
118 } // namespace content
119 #endif // CONTENT_CHILD_BLOB_STORAGE_BLOB_TRANSPORT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698