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

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

Issue 1471693006: Remove kint32min. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint3
Patch Set: rebase Created 5 years 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 | « content/browser/geolocation/wifi_data.cc ('k') | media/blink/buffered_resource_loader.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 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 MEDIA_BLINK_BUFFERED_RESOURCE_LOADER_H_ 5 #ifndef MEDIA_BLINK_BUFFERED_RESOURCE_LOADER_H_
6 #define MEDIA_BLINK_BUFFERED_RESOURCE_LOADER_H_ 6 #define MEDIA_BLINK_BUFFERED_RESOURCE_LOADER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 // |url| - URL for the resource to be loaded. 71 // |url| - URL for the resource to be loaded.
72 // |cors_mode| - HTML media element's crossorigin attribute. 72 // |cors_mode| - HTML media element's crossorigin attribute.
73 // |first_byte_position| - First byte to start loading from, 73 // |first_byte_position| - First byte to start loading from,
74 // |kPositionNotSpecified| for not specified. 74 // |kPositionNotSpecified| for not specified.
75 // |last_byte_position| - Last byte to be loaded, 75 // |last_byte_position| - Last byte to be loaded,
76 // |kPositionNotSpecified| for not specified. 76 // |kPositionNotSpecified| for not specified.
77 // |strategy| is the initial loading strategy to use. 77 // |strategy| is the initial loading strategy to use.
78 // |bitrate| is the bitrate of the media, 0 if unknown. 78 // |bitrate| is the bitrate of the media, 0 if unknown.
79 // |playback_rate| is the current playback rate of the media. 79 // |playback_rate| is the current playback rate of the media.
80 BufferedResourceLoader( 80 BufferedResourceLoader(const GURL& url,
81 const GURL& url, 81 CORSMode cors_mode,
82 CORSMode cors_mode, 82 int64_t first_byte_position,
83 int64 first_byte_position, 83 int64_t last_byte_position,
84 int64 last_byte_position, 84 DeferStrategy strategy,
85 DeferStrategy strategy, 85 int bitrate,
86 int bitrate, 86 double playback_rate,
87 double playback_rate, 87 MediaLog* media_log);
88 MediaLog* media_log);
89 ~BufferedResourceLoader() override; 88 ~BufferedResourceLoader() override;
90 89
91 // Start the resource loading with the specified URL and range. 90 // Start the resource loading with the specified URL and range.
92 // 91 //
93 // |loading_cb| is executed when the loading state has changed. 92 // |loading_cb| is executed when the loading state has changed.
94 // |progress_cb| is executed when additional data has arrived. 93 // |progress_cb| is executed when additional data has arrived.
95 typedef base::Callback<void(Status)> StartCB; 94 typedef base::Callback<void(Status)> StartCB;
96 typedef base::Callback<void(LoadingState)> LoadingStateChangedCB; 95 typedef base::Callback<void(LoadingState)> LoadingStateChangedCB;
97 typedef base::Callback<void(int64)> ProgressCB; 96 typedef base::Callback<void(int64_t)> ProgressCB;
98 void Start(const StartCB& start_cb, 97 void Start(const StartCB& start_cb,
99 const LoadingStateChangedCB& loading_cb, 98 const LoadingStateChangedCB& loading_cb,
100 const ProgressCB& progress_cb, 99 const ProgressCB& progress_cb,
101 blink::WebFrame* frame); 100 blink::WebFrame* frame);
102 101
103 // Stops everything associated with this loader, including active URL loads 102 // Stops everything associated with this loader, including active URL loads
104 // and pending callbacks. 103 // and pending callbacks.
105 // 104 //
106 // It is safe to delete a BufferedResourceLoader after calling Stop(). 105 // It is safe to delete a BufferedResourceLoader after calling Stop().
107 void Stop(); 106 void Stop();
108 107
109 // Copies |read_size| bytes from |position| into |buffer|, executing |read_cb| 108 // Copies |read_size| bytes from |position| into |buffer|, executing |read_cb|
110 // when the operation has completed. 109 // when the operation has completed.
111 // 110 //
112 // The callback will contain the number of bytes read iff the status is kOk, 111 // The callback will contain the number of bytes read iff the status is kOk,
113 // zero otherwise. 112 // zero otherwise.
114 // 113 //
115 // If necessary will temporarily increase forward capacity of buffer to 114 // If necessary will temporarily increase forward capacity of buffer to
116 // accomodate an unusually large read. 115 // accomodate an unusually large read.
117 typedef base::Callback<void(Status, int)> ReadCB; 116 typedef base::Callback<void(Status, int)> ReadCB;
118 void Read(int64 position, int read_size, 117 void Read(int64_t position,
119 uint8* buffer, const ReadCB& read_cb); 118 int read_size,
119 uint8_t* buffer,
120 const ReadCB& read_cb);
120 121
121 // Gets the content length in bytes of the instance after this loader has been 122 // Gets the content length in bytes of the instance after this loader has been
122 // started. If this value is |kPositionNotSpecified|, then content length is 123 // started. If this value is |kPositionNotSpecified|, then content length is
123 // unknown. 124 // unknown.
124 int64 content_length(); 125 int64_t content_length();
125 126
126 // Gets the original size of the file requested. If this value is 127 // Gets the original size of the file requested. If this value is
127 // |kPositionNotSpecified|, then the size is unknown. 128 // |kPositionNotSpecified|, then the size is unknown.
128 int64 instance_size(); 129 int64_t instance_size();
129 130
130 // Returns true if the server supports byte range requests. 131 // Returns true if the server supports byte range requests.
131 bool range_supported(); 132 bool range_supported();
132 133
133 // blink::WebURLLoaderClient implementation. 134 // blink::WebURLLoaderClient implementation.
134 void willFollowRedirect( 135 void willFollowRedirect(
135 blink::WebURLLoader* loader, 136 blink::WebURLLoader* loader,
136 blink::WebURLRequest& newRequest, 137 blink::WebURLRequest& newRequest,
137 const blink::WebURLResponse& redirectResponse) override; 138 const blink::WebURLResponse& redirectResponse) override;
138 void didSendData( 139 void didSendData(
139 blink::WebURLLoader* loader, 140 blink::WebURLLoader* loader,
140 unsigned long long bytesSent, 141 unsigned long long bytesSent,
141 unsigned long long totalBytesToBeSent) override; 142 unsigned long long totalBytesToBeSent) override;
142 void didReceiveResponse( 143 void didReceiveResponse(
143 blink::WebURLLoader* loader, 144 blink::WebURLLoader* loader,
144 const blink::WebURLResponse& response) override; 145 const blink::WebURLResponse& response) override;
145 void didDownloadData( 146 void didDownloadData(
146 blink::WebURLLoader* loader, 147 blink::WebURLLoader* loader,
147 int data_length, 148 int data_length,
148 int encoded_data_length) override; 149 int encoded_data_length) override;
149 void didReceiveData( 150 void didReceiveData(
150 blink::WebURLLoader* loader, 151 blink::WebURLLoader* loader,
151 const char* data, 152 const char* data,
152 int data_length, 153 int data_length,
153 int encoded_data_length) override; 154 int encoded_data_length) override;
154 void didReceiveCachedMetadata( 155 void didReceiveCachedMetadata(
155 blink::WebURLLoader* loader, 156 blink::WebURLLoader* loader,
156 const char* data, int dataLength) override; 157 const char* data, int dataLength) override;
157 void didFinishLoading( 158 void didFinishLoading(blink::WebURLLoader* loader,
158 blink::WebURLLoader* loader, 159 double finishTime,
159 double finishTime, 160 int64_t total_encoded_data_length) override;
160 int64_t total_encoded_data_length) override;
161 void didFail( 161 void didFail(
162 blink::WebURLLoader* loader, 162 blink::WebURLLoader* loader,
163 const blink::WebURLError&) override; 163 const blink::WebURLError&) override;
164 164
165 // Returns true if the media resource has a single origin, false otherwise. 165 // Returns true if the media resource has a single origin, false otherwise.
166 // Only valid to call after Start() has completed. 166 // Only valid to call after Start() has completed.
167 bool HasSingleOrigin() const; 167 bool HasSingleOrigin() const;
168 168
169 // Returns true if the media resource passed a CORS access control check. 169 // Returns true if the media resource passed a CORS access control check.
170 // Only valid to call after Start() has completed. 170 // Only valid to call after Start() has completed.
171 bool DidPassCORSAccessCheck() const; 171 bool DidPassCORSAccessCheck() const;
172 172
173 // Sets the defer strategy to the given value unless it seems unwise. 173 // Sets the defer strategy to the given value unless it seems unwise.
174 // Specifically downgrade kNeverDefer to kCapacityDefer if we know the 174 // Specifically downgrade kNeverDefer to kCapacityDefer if we know the
175 // current response will not be used to satisfy future requests (the cache 175 // current response will not be used to satisfy future requests (the cache
176 // won't help us). 176 // won't help us).
177 void UpdateDeferStrategy(DeferStrategy strategy); 177 void UpdateDeferStrategy(DeferStrategy strategy);
178 178
179 // Sets the playback rate to the given value and updates buffer window 179 // Sets the playback rate to the given value and updates buffer window
180 // accordingly. 180 // accordingly.
181 void SetPlaybackRate(double playback_rate); 181 void SetPlaybackRate(double playback_rate);
182 182
183 // Sets the bitrate to the given value and updates buffer window 183 // Sets the bitrate to the given value and updates buffer window
184 // accordingly. 184 // accordingly.
185 void SetBitrate(int bitrate); 185 void SetBitrate(int bitrate);
186 186
187 // Return the |first_byte_position| passed into the ctor. 187 // Return the |first_byte_position| passed into the ctor.
188 int64 first_byte_position() const; 188 int64_t first_byte_position() const;
189 189
190 // Parse a Content-Range header into its component pieces and return true if 190 // Parse a Content-Range header into its component pieces and return true if
191 // each of the expected elements was found & parsed correctly. 191 // each of the expected elements was found & parsed correctly.
192 // |*instance_size| may be set to kPositionNotSpecified if the range ends in 192 // |*instance_size| may be set to kPositionNotSpecified if the range ends in
193 // "/*". 193 // "/*".
194 // NOTE: only public for testing! This is an implementation detail of 194 // NOTE: only public for testing! This is an implementation detail of
195 // VerifyPartialResponse (a private method). 195 // VerifyPartialResponse (a private method).
196 static bool ParseContentRange( 196 static bool ParseContentRange(const std::string& content_range_str,
197 const std::string& content_range_str, int64* first_byte_position, 197 int64_t* first_byte_position,
198 int64* last_byte_position, int64* instance_size); 198 int64_t* last_byte_position,
199 int64_t* instance_size);
199 200
200 // Cancels and closes any outstanding deferred ActiveLoader instances. Does 201 // Cancels and closes any outstanding deferred ActiveLoader instances. Does
201 // not report a failed state, so subsequent read calls to cache may still 202 // not report a failed state, so subsequent read calls to cache may still
202 // complete okay. If the ActiveLoader is not deferred it will be canceled once 203 // complete okay. If the ActiveLoader is not deferred it will be canceled once
203 // it is unless playback starts before then (as determined by the reported 204 // it is unless playback starts before then (as determined by the reported
204 // playback rate). 205 // playback rate).
205 void CancelUponDeferral(); 206 void CancelUponDeferral();
206 207
207 // Returns the original URL of the response. If the request is redirected to 208 // Returns the original URL of the response. If the request is redirected to
208 // another URL it is the URL after redirected. If the response is generated in 209 // another URL it is the URL after redirected. If the response is generated in
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 bool might_be_reused_from_cache_in_future_; 279 bool might_be_reused_from_cache_in_future_;
279 280
280 // True if Range header is supported. 281 // True if Range header is supported.
281 bool range_supported_; 282 bool range_supported_;
282 283
283 // Forward capacity to reset to after an extension. 284 // Forward capacity to reset to after an extension.
284 int saved_forward_capacity_; 285 int saved_forward_capacity_;
285 286
286 GURL url_; 287 GURL url_;
287 CORSMode cors_mode_; 288 CORSMode cors_mode_;
288 const int64 first_byte_position_; 289 const int64_t first_byte_position_;
289 const int64 last_byte_position_; 290 const int64_t last_byte_position_;
290 bool single_origin_; 291 bool single_origin_;
291 292
292 // Executed whenever the state of resource loading has changed. 293 // Executed whenever the state of resource loading has changed.
293 LoadingStateChangedCB loading_cb_; 294 LoadingStateChangedCB loading_cb_;
294 295
295 // Executed whenever additional data has been downloaded and reports the 296 // Executed whenever additional data has been downloaded and reports the
296 // zero-indexed file offset of the furthest buffered byte. 297 // zero-indexed file offset of the furthest buffered byte.
297 ProgressCB progress_cb_; 298 ProgressCB progress_cb_;
298 299
299 // Members used during request start. 300 // Members used during request start.
300 StartCB start_cb_; 301 StartCB start_cb_;
301 int64 offset_; 302 int64_t offset_;
302 int64 content_length_; 303 int64_t content_length_;
303 int64 instance_size_; 304 int64_t instance_size_;
304 305
305 // Members used during a read operation. They should be reset after each 306 // Members used during a read operation. They should be reset after each
306 // read has completed or failed. 307 // read has completed or failed.
307 ReadCB read_cb_; 308 ReadCB read_cb_;
308 int64 read_position_; 309 int64_t read_position_;
309 int read_size_; 310 int read_size_;
310 uint8* read_buffer_; 311 uint8_t* read_buffer_;
311 312
312 // Offsets of the requested first byte and last byte in |buffer_|. They are 313 // Offsets of the requested first byte and last byte in |buffer_|. They are
313 // written by Read(). 314 // written by Read().
314 int first_offset_; 315 int first_offset_;
315 int last_offset_; 316 int last_offset_;
316 317
317 // Injected WebURLLoader instance for testing purposes. 318 // Injected WebURLLoader instance for testing purposes.
318 scoped_ptr<blink::WebURLLoader> test_loader_; 319 scoped_ptr<blink::WebURLLoader> test_loader_;
319 320
320 // Bitrate of the media. Set to 0 if unknown. 321 // Bitrate of the media. Set to 0 if unknown.
321 int bitrate_; 322 int bitrate_;
322 323
323 // Playback rate of the media. 324 // Playback rate of the media.
324 double playback_rate_; 325 double playback_rate_;
325 326
326 GURL response_original_url_; 327 GURL response_original_url_;
327 328
328 scoped_refptr<MediaLog> media_log_; 329 scoped_refptr<MediaLog> media_log_;
329 330
330 bool cancel_upon_deferral_; 331 bool cancel_upon_deferral_;
331 332
332 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); 333 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader);
333 }; 334 };
334 335
335 } // namespace media 336 } // namespace media
336 337
337 #endif // MEDIA_BLINK_BUFFERED_RESOURCE_LOADER_H_ 338 #endif // MEDIA_BLINK_BUFFERED_RESOURCE_LOADER_H_
OLDNEW
« no previous file with comments | « content/browser/geolocation/wifi_data.cc ('k') | media/blink/buffered_resource_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698