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

Side by Side Diff: media/blink/url_index.h

Issue 2910553002: fully cache small audio/video (Closed)
Patch Set: comment added Created 3 years, 6 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
« no previous file with comments | « media/blink/resource_multibuffer_data_provider.cc ('k') | media/blink/url_index.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 MEDIA_BLINK_URL_INDEX_H_ 5 #ifndef MEDIA_BLINK_URL_INDEX_H_
6 #define MEDIA_BLINK_URL_INDEX_H_ 6 #define MEDIA_BLINK_URL_INDEX_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 // The key used by UrlIndex to find this UrlData. 85 // The key used by UrlIndex to find this UrlData.
86 KeyType key() const; 86 KeyType key() const;
87 87
88 // Length of data associated with url or |kPositionNotSpecified| 88 // Length of data associated with url or |kPositionNotSpecified|
89 int64_t length() const { return length_; } 89 int64_t length() const { return length_; }
90 90
91 // Returns the number of blocks cached for this resource. 91 // Returns the number of blocks cached for this resource.
92 size_t CachedSize(); 92 size_t CachedSize();
93 93
94 // Returns true if this resource is fully cached in memory.
95 bool FullyCached();
96
94 // Returns our url_index, or nullptr if it's been destroyed. 97 // Returns our url_index, or nullptr if it's been destroyed.
95 UrlIndex* url_index() const { return url_index_.get(); } 98 UrlIndex* url_index() const { return url_index_.get(); }
96 99
97 // Notifies the url index that this is currently used. 100 // Notifies the url index that this is currently used.
98 // The url <-> URLData mapping will be eventually be invalidated if 101 // The url <-> URLData mapping will be eventually be invalidated if
99 // this is not called regularly. 102 // this is not called regularly.
100 void Use(); 103 void Use();
101 104
102 // Call this before we add some data to the multibuffer(). 105 // Call this before we add some data to the multibuffer().
103 // If the multibuffer is empty, the data origin is set from 106 // If the multibuffer is empty, the data origin is set from
(...skipping 20 matching lines...) Expand all
124 typedef base::Callback<void(const scoped_refptr<UrlData>&)> RedirectCB; 127 typedef base::Callback<void(const scoped_refptr<UrlData>&)> RedirectCB;
125 128
126 // Register a callback to be called when a redirect occurs. 129 // Register a callback to be called when a redirect occurs.
127 // Callbacks are cleared when a redirect occurs, so clients must call 130 // Callbacks are cleared when a redirect occurs, so clients must call
128 // OnRedirect again if they wish to continue receiving callbacks. 131 // OnRedirect again if they wish to continue receiving callbacks.
129 void OnRedirect(const RedirectCB& cb); 132 void OnRedirect(const RedirectCB& cb);
130 133
131 // Returns true it is valid to keep using this to access cached data. 134 // Returns true it is valid to keep using this to access cached data.
132 // A single media player instance may choose to ignore this for resources 135 // A single media player instance may choose to ignore this for resources
133 // that have already been opened. 136 // that have already been opened.
134 bool Valid() const; 137 bool Valid();
135 138
136 // Virtual so we can override it for testing. 139 // Virtual so we can override it for testing.
137 virtual ResourceMultiBuffer* multibuffer(); 140 virtual ResourceMultiBuffer* multibuffer();
138 141
139 // Accessor 142 // Accessor
140 blink::WebFrame* frame() const { return frame_; } 143 blink::WebFrame* frame() const { return frame_; }
141 144
142 void AddBytesRead(int64_t b) { bytes_read_from_cache_ += b; } 145 void AddBytesRead(int64_t b) { bytes_read_from_cache_ += b; }
143 int64_t BytesReadFromCache() { return bytes_read_from_cache_; } 146 int64_t BytesReadFromCache() { return bytes_read_from_cache_; }
144 147
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // log2 of block size in multibuffer cache. Defaults to kBlockSizeShift. 261 // log2 of block size in multibuffer cache. Defaults to kBlockSizeShift.
259 // Currently only changed for testing purposes. 262 // Currently only changed for testing purposes.
260 const int block_shift_; 263 const int block_shift_;
261 264
262 protected: 265 protected:
263 base::WeakPtrFactory<UrlIndex> weak_factory_; 266 base::WeakPtrFactory<UrlIndex> weak_factory_;
264 }; 267 };
265 268
266 } // namespace media 269 } // namespace media
267 #endif // MEDIA_BLINK_URL_INDEX_H_ 270 #endif // MEDIA_BLINK_URL_INDEX_H_
OLDNEW
« no previous file with comments | « media/blink/resource_multibuffer_data_provider.cc ('k') | media/blink/url_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698