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

Side by Side Diff: storage/browser/blob/blob_transport_strategy.h

Issue 1098853003: [BlobAsync] Patch 4: Browser Classes & Logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Non C++11 fixes, added nodisk logic and test Created 5 years, 7 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
(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 STORAGE_BROWSER_BLOB_BLOB_TRANSPORT_STRATEGY_H_
6 #define STORAGE_BROWSER_BLOB_BLOB_TRANSPORT_STRATEGY_H_
7
8 #include <vector>
9
10 #include "base/macros.h"
11 #include "storage/browser/storage_browser_export.h"
12 #include "storage/common/data_element.h"
13 #include "storage/common/fileapi/blob_item_bytes_request.h"
14
15 namespace storage {
16
17 // This class determines and stores the strategy for asynchronously transporting
18 // memory from the renderer to the browser. This involves two transformations:
19 // 1. Transforming the data storage to be efficient in-transport. This can
20 // mean that data is consolidated from cross-blob or cross-file boundaries
21 // in the blob in a common block of shared memory or a file.
22 // 2. Transforming the transport data into the browser storage representation.
23 // This can simply mirror the renderer representation, or it can be instead
24 // pointing to transport representation with offsets and sizes.
25 //
26 // The initial implementation of this is simple, but the protocol allows any
27 // sort of flexibility, as everything has an offset and size specified.
28 class STORAGE_EXPORT BlobTransportStrategy {
29 public:
30 enum Mode { MODE_UNKNOWN = 0, MODE_NO_DISK, MODE_DISK };
31
32 enum Error {
33 ERROR_NONE = 0,
34 ERROR_TOO_LARGE, // This item can't fit in disk or memory
35 ERROR_INVALID_PARAMS
36 };
37
38 struct MemoryItemRequest {
39 size_t browser_item_index;
40 size_t browser_item_offset;
41 BlobItemBytesRequest message;
42 };
43
44 BlobTransportStrategy();
45 virtual ~BlobTransportStrategy();
46
47 void Initialize(Mode mode, size_t max_ipc_memory_size,
48 size_t max_shared_memory_size, uint64_t max_file_size,
49 size_t max_blob_in_memory_size, uint64_t disk_space_left,
50 size_t memory_left,
51 const std::vector<DataElement> blob_item_infos);
kinuko 2015/04/30 15:04:21 nit: split the lines to have one parameter for eac
dmurph 2015/05/07 02:07:39 Done.
52
53 std::vector<uint64_t>& file_handles() { return file_handles_; }
54
55 std::vector<size_t>& shared_memory_handles() {
56 return shared_memory_handles_;
57 }
kinuko 2015/04/30 15:04:21 Are these intentionally made non-const references?
dmurph 2015/05/07 02:07:39 Whoops, done.
58
59 const std::vector<MemoryItemRequest>& requests() const { return requests_; }
60
61 Error error() const { return error_; }
62
63 // This iterates of the data elements and segments the 'bytes' data into
64 // the smallest number of segments given the max_segment_size.
65 // The callback describes either:
66 // * A non-memory item
67 // * A partition of a bytes element which will be populated into a given
68 // segment and segment offset.
69 // The function signature of the template functor is:
70 // void(DataElement::Type /*element_type*/,
71 // size_t /*element_index*/,
72 // SizeType /*element_offset*/,
73 // size_t /*segment_index*/,
74 // SizeType /*segment_offset*/,
75 // SizeType /*size*/)
kinuko 2015/04/30 15:04:21 would be nice to have a rough explanation about 'e
dmurph 2015/05/07 02:07:39 Done.
76 //
77 // Assumptions: All memory items are consolidated. As in, there are no two
78 // 'bytes' items next to eachother.
79 template <typename ForEachFunctor, typename SizeType>
80 static void ForEachWithSegment(const std::vector<DataElement> items,
kinuko 2015/04/30 15:04:21 nit: const ref
kinuko 2015/04/30 15:04:21 This could be private?
dmurph 2015/05/07 02:07:39 Done, done.
81 SizeType max_segment_size,
82 ForEachFunctor function);
83
84 private:
85 Error error_;
86
87 std::vector<uint64_t> file_handles_;
88 // can be size_t, but same as file handles so we can use the same methods.
kinuko 2015/04/30 15:04:21 ?
dmurph 2015/05/07 02:07:39 Whoops, forgot to remove this.
89 std::vector<size_t> shared_memory_handles_;
90
91 std::vector<MemoryItemRequest> requests_;
92
93 DISALLOW_COPY_AND_ASSIGN(BlobTransportStrategy);
94 };
95
96 } // namespace storage
97
98 #endif // STORAGE_BROWSER_BLOB_BLOB_TRANSPORT_STRATEGY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698