Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2010 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 #include "base/format_macros.h" | |
| 6 #include "base/string_util.h" | |
| 7 #include "net/base/net_errors.h" | |
| 8 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" | |
| 9 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" | |
| 10 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | |
| 11 #include "third_party/WebKit/WebKit/chromium/public/WebURLError.h" | |
| 12 #include "webkit/glue/media/buffered_resource_loader.h" | |
|
scherkus (not reviewing)
2010/12/10 23:02:38
can you move this header to the first line + fix a
annacc
2010/12/11 20:12:38
Done.
| |
| 13 #include "webkit/glue/multipart_response_delegate.h" | |
| 14 #include "webkit/glue/webkit_glue.h" | |
| 15 #include "webkit/glue/webmediaplayer_impl.h" | |
| 16 | |
| 17 using WebKit::WebFrame; | |
| 18 using WebKit::WebString; | |
| 19 using WebKit::WebURLError; | |
| 20 using WebKit::WebURLLoader; | |
| 21 using WebKit::WebURLRequest; | |
| 22 using WebKit::WebURLResponse; | |
| 23 using webkit_glue::MultipartResponseDelegate; | |
| 24 | |
| 25 namespace { | |
| 26 | |
| 27 const char kHttpScheme[] = "http"; | |
| 28 const char kHttpsScheme[] = "https"; | |
| 29 const char kDataScheme[] = "data"; | |
| 30 const int64 kPositionNotSpecified = -1; | |
| 31 const int kHttpOK = 200; | |
| 32 const int kHttpPartialContent = 206; | |
| 33 | |
| 34 // Define the number of bytes in a megabyte. | |
| 35 const size_t kMegabyte = 1024 * 1024; | |
| 36 | |
| 37 // Backward capacity of the buffer, by default 2MB. | |
| 38 const size_t kBackwardCapcity = 2 * kMegabyte; | |
| 39 | |
| 40 // Forward capacity of the buffer, by default 10MB. | |
| 41 const size_t kForwardCapacity = 10 * kMegabyte; | |
| 42 | |
| 43 // The threshold of bytes that we should wait until the data arrives in the | |
| 44 // future instead of restarting a new connection. This number is defined in the | |
| 45 // number of bytes, we should determine this value from typical connection speed | |
| 46 // and amount of time for a suitable wait. Now I just make a guess for this | |
| 47 // number to be 2MB. | |
| 48 // TODO(hclam): determine a better value for this. | |
|
scherkus (not reviewing)
2010/12/10 23:02:38
could you change the TODO to reference crbug.com/6
annacc
2010/12/11 20:12:38
Done.
| |
| 49 const int kForwardWaitThreshold = 2 * kMegabyte; | |
| 50 | |
| 51 // Returns true if |url| operates on HTTP protocol. | |
| 52 bool IsHttpProtocol(const GURL& url) { | |
| 53 return url.SchemeIs(kHttpScheme) || url.SchemeIs(kHttpsScheme); | |
| 54 } | |
| 55 | |
| 56 bool IsDataProtocol(const GURL& url) { | |
| 57 return url.SchemeIs(kDataScheme); | |
| 58 } | |
| 59 | |
| 60 } // namespace | |
| 61 | |
| 62 namespace webkit_glue { | |
| 63 | |
| 64 ///////////////////////////////////////////////////////////////////////////// | |
|
scherkus (not reviewing)
2010/12/10 23:02:38
ditto w.r.t. noisy comments
annacc
2010/12/11 20:12:38
Done.
| |
| 65 // BufferedResourceLoader | |
| 66 BufferedResourceLoader::BufferedResourceLoader( | |
| 67 const GURL& url, | |
| 68 int64 first_byte_position, | |
| 69 int64 last_byte_position) | |
| 70 : buffer_(new media::SeekableBuffer(kBackwardCapcity, kForwardCapacity)), | |
| 71 deferred_(false), | |
| 72 defer_allowed_(true), | |
| 73 completed_(false), | |
| 74 range_requested_(false), | |
| 75 partial_response_(false), | |
| 76 url_(url), | |
| 77 first_byte_position_(first_byte_position), | |
| 78 last_byte_position_(last_byte_position), | |
| 79 start_callback_(NULL), | |
| 80 offset_(0), | |
| 81 content_length_(kPositionNotSpecified), | |
| 82 instance_size_(kPositionNotSpecified), | |
| 83 read_callback_(NULL), | |
| 84 read_position_(0), | |
| 85 read_size_(0), | |
| 86 read_buffer_(NULL), | |
| 87 first_offset_(0), | |
| 88 last_offset_(0), | |
| 89 keep_test_loader_(false) { | |
| 90 } | |
| 91 | |
| 92 BufferedResourceLoader::~BufferedResourceLoader() { | |
| 93 if (!completed_ && url_loader_.get()) | |
| 94 url_loader_->cancel(); | |
| 95 } | |
| 96 | |
| 97 void BufferedResourceLoader::Start(net::CompletionCallback* start_callback, | |
| 98 NetworkEventCallback* event_callback, | |
| 99 WebFrame* frame) { | |
| 100 // Make sure we have not started. | |
| 101 DCHECK(!start_callback_.get()); | |
| 102 DCHECK(!event_callback_.get()); | |
| 103 DCHECK(start_callback); | |
| 104 DCHECK(event_callback); | |
| 105 CHECK(frame); | |
| 106 | |
| 107 start_callback_.reset(start_callback); | |
| 108 event_callback_.reset(event_callback); | |
| 109 | |
| 110 if (first_byte_position_ != kPositionNotSpecified) { | |
| 111 range_requested_ = true; | |
| 112 // TODO(hclam): server may not support range request so |offset_| may not | |
| 113 // equal to |first_byte_position_|. | |
| 114 offset_ = first_byte_position_; | |
| 115 } | |
| 116 | |
| 117 // Increment the reference count right before we start the request. This | |
| 118 // reference will be release when this request has ended. | |
| 119 AddRef(); | |
| 120 | |
| 121 // Prepare the request. | |
| 122 WebURLRequest request(url_); | |
| 123 request.setHTTPHeaderField(WebString::fromUTF8("Range"), | |
| 124 WebString::fromUTF8(GenerateHeaders( | |
| 125 first_byte_position_, | |
| 126 last_byte_position_))); | |
| 127 frame->setReferrerForRequest(request, WebKit::WebURL()); | |
| 128 // TODO(annacc): we should be using createAssociatedURLLoader() instead? | |
| 129 frame->dispatchWillSendRequest(request); | |
| 130 | |
| 131 // This flag is for unittests as we don't want to reset |url_loader| | |
| 132 if (!keep_test_loader_) | |
| 133 url_loader_.reset(WebKit::webKitClient()->createURLLoader()); | |
| 134 | |
| 135 // Start the resource loading. | |
| 136 url_loader_->loadAsynchronously(request, this); | |
| 137 } | |
| 138 | |
| 139 void BufferedResourceLoader::Stop() { | |
| 140 // Reset callbacks. | |
| 141 start_callback_.reset(); | |
| 142 event_callback_.reset(); | |
| 143 read_callback_.reset(); | |
| 144 | |
| 145 // Use the internal buffer to signal that we have been stopped. | |
| 146 // TODO(hclam): Not so pretty to do this. | |
| 147 if (!buffer_.get()) | |
| 148 return; | |
| 149 | |
| 150 // Destroy internal buffer. | |
| 151 buffer_.reset(); | |
| 152 | |
| 153 if (url_loader_.get()) { | |
| 154 if (deferred_) | |
| 155 url_loader_->setDefersLoading(false); | |
| 156 deferred_ = false; | |
| 157 | |
| 158 if (!completed_) { | |
| 159 url_loader_->cancel(); | |
| 160 completed_ = true; | |
| 161 } | |
| 162 } | |
| 163 } | |
| 164 | |
| 165 void BufferedResourceLoader::Read(int64 position, | |
| 166 int read_size, | |
| 167 uint8* buffer, | |
| 168 net::CompletionCallback* read_callback) { | |
| 169 DCHECK(!read_callback_.get()); | |
| 170 DCHECK(buffer_.get()); | |
| 171 DCHECK(read_callback); | |
| 172 DCHECK(buffer); | |
| 173 | |
| 174 // Save the parameter of reading. | |
| 175 read_callback_.reset(read_callback); | |
| 176 read_position_ = position; | |
| 177 read_size_ = read_size; | |
| 178 read_buffer_ = buffer; | |
| 179 | |
| 180 // If read position is beyond the instance size, we cannot read there. | |
| 181 if (instance_size_ != kPositionNotSpecified && | |
| 182 instance_size_ <= read_position_) { | |
| 183 DoneRead(0); | |
| 184 return; | |
| 185 } | |
| 186 | |
| 187 // Make sure |offset_| and |read_position_| does not differ by a large | |
| 188 // amount. | |
| 189 if (read_position_ > offset_ + kint32max || | |
| 190 read_position_ < offset_ + kint32min) { | |
| 191 DoneRead(net::ERR_CACHE_MISS); | |
| 192 return; | |
| 193 } | |
| 194 | |
| 195 // Prepare the parameters. | |
| 196 first_offset_ = static_cast<int>(read_position_ - offset_); | |
| 197 last_offset_ = first_offset_ + read_size_; | |
| 198 | |
| 199 // If we can serve the request now, do the actual read. | |
| 200 if (CanFulfillRead()) { | |
| 201 ReadInternal(); | |
| 202 DisableDeferIfNeeded(); | |
| 203 return; | |
| 204 } | |
| 205 | |
| 206 // If we expected the read request to be fulfilled later, returns | |
| 207 // immediately and let more data to flow in. | |
| 208 if (WillFulfillRead()) | |
| 209 return; | |
| 210 | |
| 211 // Make a callback to report failure. | |
| 212 DoneRead(net::ERR_CACHE_MISS); | |
| 213 } | |
| 214 | |
| 215 int64 BufferedResourceLoader::GetBufferedFirstBytePosition() { | |
| 216 if (buffer_.get()) | |
| 217 return offset_ - static_cast<int>(buffer_->backward_bytes()); | |
| 218 return kPositionNotSpecified; | |
| 219 } | |
| 220 | |
| 221 int64 BufferedResourceLoader::GetBufferedLastBytePosition() { | |
| 222 if (buffer_.get()) | |
| 223 return offset_ + static_cast<int>(buffer_->forward_bytes()) - 1; | |
| 224 return kPositionNotSpecified; | |
| 225 } | |
| 226 | |
| 227 void BufferedResourceLoader::SetAllowDefer(bool is_allowed) { | |
| 228 defer_allowed_ = is_allowed; | |
| 229 DisableDeferIfNeeded(); | |
| 230 } | |
| 231 | |
| 232 void BufferedResourceLoader::SetURLLoaderForTest(WebURLLoader* mock_loader) { | |
| 233 url_loader_.reset(mock_loader); | |
| 234 keep_test_loader_ = true; | |
| 235 } | |
| 236 | |
| 237 ///////////////////////////////////////////////////////////////////////////// | |
| 238 // BufferedResourceLoader, WebKit::WebURLLoaderClient implementations. | |
|
scherkus (not reviewing)
2010/12/10 23:02:38
ditto w.r.t. noisy comments
annacc
2010/12/11 20:12:38
Done.
| |
| 239 void BufferedResourceLoader::willSendRequest( | |
| 240 WebURLLoader* loader, | |
| 241 WebURLRequest& newRequest, | |
| 242 const WebURLResponse& redirectResponse) { | |
| 243 | |
| 244 // The load may have been stopped and |start_callback| is destroyed. | |
| 245 // In this case we shouldn't do anything. | |
| 246 if (!start_callback_.get()) { | |
| 247 // Set the url in the request to an invalid value (empty url). | |
| 248 newRequest.setURL(WebKit::WebURL()); | |
| 249 return; | |
| 250 } | |
| 251 | |
| 252 if (!IsProtocolSupportedForMedia(newRequest.url())) { | |
| 253 // Set the url in the request to an invalid value (empty url). | |
| 254 newRequest.setURL(WebKit::WebURL()); | |
| 255 DoneStart(net::ERR_ADDRESS_INVALID); | |
| 256 Stop(); | |
| 257 return; | |
| 258 } | |
| 259 | |
| 260 url_ = newRequest.url(); | |
| 261 } | |
| 262 | |
| 263 void BufferedResourceLoader::didSendData( | |
| 264 WebURLLoader* loader, | |
| 265 unsigned long long bytes_sent, | |
| 266 unsigned long long total_bytes_to_be_sent) { | |
| 267 NOTIMPLEMENTED(); | |
| 268 } | |
| 269 | |
| 270 void BufferedResourceLoader::didReceiveResponse( | |
| 271 WebURLLoader* loader, | |
| 272 const WebURLResponse& response) { | |
| 273 | |
| 274 // The loader may have been stopped and |start_callback| is destroyed. | |
| 275 // In this case we shouldn't do anything. | |
| 276 if (!start_callback_.get()) | |
| 277 return; | |
| 278 | |
| 279 // We make a strong assumption that when we reach here we have either | |
| 280 // received a response from HTTP/HTTPS protocol or the request was | |
| 281 // successful (in particular range request). So we only verify the partial | |
| 282 // response for HTTP and HTTPS protocol. | |
| 283 if (IsHttpProtocol(url_)) { | |
| 284 int error = net::OK; | |
| 285 | |
| 286 if (response.httpStatusCode() == kHttpPartialContent) | |
| 287 partial_response_ = true; | |
| 288 | |
| 289 if (range_requested_ && partial_response_) { | |
| 290 // If we have verified the partial response and it is correct, we will | |
| 291 // return net::OK. | |
| 292 if (!VerifyPartialResponse(response)) | |
| 293 error = net::ERR_INVALID_RESPONSE; | |
| 294 } else if (response.httpStatusCode() != kHttpOK) { | |
| 295 // We didn't request a range but server didn't reply with "200 OK". | |
| 296 error = net::ERR_FAILED; | |
| 297 } | |
| 298 | |
| 299 if (error != net::OK) { | |
| 300 DoneStart(error); | |
| 301 Stop(); | |
| 302 return; | |
| 303 } | |
| 304 } else { | |
| 305 // For any protocol other than HTTP and HTTPS, assume range request is | |
| 306 // always fulfilled. | |
| 307 partial_response_ = range_requested_; | |
| 308 } | |
| 309 | |
| 310 // Expected content length can be -1, in that case |content_length_| is | |
| 311 // not specified and this is a streaming response. | |
| 312 content_length_ = response.expectedContentLength(); | |
| 313 | |
| 314 // If we have not requested a range, then the size of the instance is equal | |
| 315 // to the content length. | |
| 316 if (!partial_response_) | |
| 317 instance_size_ = content_length_; | |
| 318 | |
| 319 // Calls with a successful response. | |
| 320 DoneStart(net::OK); | |
| 321 } | |
| 322 | |
| 323 void BufferedResourceLoader::didReceiveData( | |
| 324 WebURLLoader* loader, | |
| 325 const char* data, | |
| 326 int data_length) { | |
| 327 DCHECK(!completed_); | |
| 328 DCHECK_GT(data_length, 0); | |
| 329 | |
| 330 // If this loader has been stopped, |buffer_| would be destroyed. | |
| 331 // In this case we shouldn't do anything. | |
| 332 if (!buffer_.get()) | |
| 333 return; | |
| 334 | |
| 335 // Writes more data to |buffer_|. | |
| 336 buffer_->Append(reinterpret_cast<const uint8*>(data), data_length); | |
| 337 | |
| 338 // If there is an active read request, try to fulfill the request. | |
| 339 if (HasPendingRead() && CanFulfillRead()) { | |
| 340 ReadInternal(); | |
| 341 } else if (!defer_allowed_) { | |
| 342 // If we're not allowed to defer, slide the buffer window forward instead | |
| 343 // of deferring. | |
| 344 if (buffer_->forward_bytes() > buffer_->forward_capacity()) { | |
| 345 size_t excess = buffer_->forward_bytes() - buffer_->forward_capacity(); | |
| 346 bool success = buffer_->Seek(excess); | |
| 347 DCHECK(success); | |
| 348 offset_ += first_offset_ + excess; | |
| 349 } | |
| 350 } | |
| 351 | |
| 352 // At last see if the buffer is full and we need to defer the downloading. | |
| 353 EnableDeferIfNeeded(); | |
| 354 | |
| 355 // Notify that we have received some data. | |
| 356 NotifyNetworkEvent(); | |
| 357 } | |
| 358 | |
| 359 void BufferedResourceLoader::didDownloadData( | |
| 360 WebKit::WebURLLoader* loader, | |
| 361 int dataLength) { | |
| 362 NOTIMPLEMENTED(); | |
| 363 } | |
| 364 | |
| 365 void BufferedResourceLoader::didReceiveCachedMetadata( | |
| 366 WebURLLoader* loader, | |
| 367 const char* data, | |
| 368 int data_length) { | |
| 369 NOTIMPLEMENTED(); | |
| 370 } | |
| 371 | |
| 372 void BufferedResourceLoader::didFinishLoading( | |
| 373 WebURLLoader* loader, | |
| 374 double finishTime) { | |
| 375 DCHECK(!completed_); | |
| 376 completed_ = true; | |
| 377 | |
| 378 // If there is a start callback, calls it. | |
| 379 if (start_callback_.get()) { | |
| 380 DoneStart(net::OK); | |
| 381 } | |
| 382 | |
| 383 // If there is a pending read but the request has ended, returns with what | |
| 384 // we have. | |
| 385 if (HasPendingRead()) { | |
| 386 // Make sure we have a valid buffer before we satisfy a read request. | |
| 387 DCHECK(buffer_.get()); | |
| 388 | |
| 389 // Try to fulfill with what is in the buffer. | |
| 390 if (CanFulfillRead()) | |
| 391 ReadInternal(); | |
| 392 else | |
| 393 DoneRead(net::ERR_CACHE_MISS); | |
| 394 } | |
| 395 | |
| 396 // There must not be any outstanding read request. | |
| 397 DCHECK(!HasPendingRead()); | |
| 398 | |
| 399 // Notify that network response is completed. | |
| 400 NotifyNetworkEvent(); | |
| 401 | |
| 402 url_loader_.reset(); | |
| 403 Release(); | |
| 404 } | |
| 405 | |
| 406 void BufferedResourceLoader::didFail( | |
| 407 WebURLLoader* loader, | |
| 408 const WebURLError& error) { | |
| 409 DCHECK(!completed_); | |
| 410 completed_ = true; | |
| 411 | |
| 412 // If there is a start callback, calls it. | |
| 413 if (start_callback_.get()) { | |
| 414 DoneStart(error.reason); | |
| 415 } | |
| 416 | |
| 417 // If there is a pending read but the request failed, return with the | |
| 418 // reason for the error. | |
| 419 if (HasPendingRead()) { | |
| 420 DoneRead(error.reason); | |
| 421 } | |
| 422 | |
| 423 // Notify that network response is completed. | |
| 424 NotifyNetworkEvent(); | |
| 425 | |
| 426 url_loader_.reset(); | |
| 427 Release(); | |
| 428 } | |
| 429 | |
| 430 ///////////////////////////////////////////////////////////////////////////// | |
| 431 // BufferedResourceLoader, private | |
|
scherkus (not reviewing)
2010/12/10 23:02:38
ditto w.r.t. noisy comments
annacc
2010/12/11 20:12:38
Done.
| |
| 432 void BufferedResourceLoader::EnableDeferIfNeeded() { | |
| 433 if (!defer_allowed_) | |
| 434 return; | |
| 435 | |
| 436 if (!deferred_ && | |
| 437 buffer_->forward_bytes() >= buffer_->forward_capacity()) { | |
| 438 deferred_ = true; | |
| 439 | |
| 440 if (url_loader_.get()) | |
| 441 url_loader_->setDefersLoading(true); | |
| 442 | |
| 443 NotifyNetworkEvent(); | |
| 444 } | |
| 445 } | |
| 446 | |
| 447 void BufferedResourceLoader::DisableDeferIfNeeded() { | |
| 448 if (deferred_ && | |
| 449 (!defer_allowed_ || | |
| 450 buffer_->forward_bytes() < buffer_->forward_capacity() / 2)) { | |
| 451 deferred_ = false; | |
| 452 | |
| 453 if (url_loader_.get()) | |
| 454 url_loader_->setDefersLoading(false); | |
| 455 | |
| 456 NotifyNetworkEvent(); | |
| 457 } | |
| 458 } | |
| 459 | |
| 460 bool BufferedResourceLoader::CanFulfillRead() { | |
| 461 // If we are reading too far in the backward direction. | |
| 462 if (first_offset_ < 0 && | |
| 463 first_offset_ + static_cast<int>(buffer_->backward_bytes()) < 0) | |
| 464 return false; | |
| 465 | |
| 466 // If the start offset is too far ahead. | |
| 467 if (first_offset_ >= static_cast<int>(buffer_->forward_bytes())) | |
| 468 return false; | |
| 469 | |
| 470 // At the point, we verified that first byte requested is within the buffer. | |
| 471 // If the request has completed, then just returns with what we have now. | |
| 472 if (completed_) | |
| 473 return true; | |
| 474 | |
| 475 // If the resource request is still active, make sure the whole requested | |
| 476 // range is covered. | |
| 477 if (last_offset_ > static_cast<int>(buffer_->forward_bytes())) | |
| 478 return false; | |
| 479 | |
| 480 return true; | |
| 481 } | |
| 482 | |
| 483 bool BufferedResourceLoader::WillFulfillRead() { | |
| 484 // Reading too far in the backward direction. | |
| 485 if (first_offset_ < 0 && | |
| 486 first_offset_ + static_cast<int>(buffer_->backward_bytes()) < 0) | |
| 487 return false; | |
| 488 | |
| 489 // Try to read too far ahead. | |
| 490 if (last_offset_ > kForwardWaitThreshold) | |
| 491 return false; | |
| 492 | |
| 493 // The resource request has completed, there's no way we can fulfill the | |
| 494 // read request. | |
| 495 if (completed_) | |
| 496 return false; | |
| 497 | |
| 498 return true; | |
| 499 } | |
| 500 | |
| 501 void BufferedResourceLoader::ReadInternal() { | |
| 502 // Seek to the first byte requested. | |
| 503 bool ret = buffer_->Seek(first_offset_); | |
| 504 DCHECK(ret); | |
| 505 | |
| 506 // Then do the read. | |
| 507 int read = static_cast<int>(buffer_->Read(read_buffer_, read_size_)); | |
| 508 offset_ += first_offset_ + read; | |
| 509 | |
| 510 // And report with what we have read. | |
| 511 DoneRead(read); | |
| 512 } | |
| 513 | |
| 514 bool BufferedResourceLoader::VerifyPartialResponse( | |
| 515 const WebURLResponse& response) { | |
| 516 int first_byte_position, last_byte_position, instance_size; | |
| 517 | |
| 518 if (!MultipartResponseDelegate::ReadContentRanges(response, | |
| 519 &first_byte_position, | |
| 520 &last_byte_position, | |
| 521 &instance_size)) { | |
| 522 return false; | |
| 523 } | |
| 524 | |
| 525 if (instance_size != kPositionNotSpecified) { | |
| 526 instance_size_ = instance_size; | |
| 527 } | |
| 528 | |
| 529 if (first_byte_position_ != kPositionNotSpecified && | |
| 530 first_byte_position_ != first_byte_position) { | |
| 531 return false; | |
| 532 } | |
| 533 | |
| 534 // TODO(hclam): I should also check |last_byte_position|, but since | |
| 535 // we will never make such a request that it is ok to leave it unimplemented. | |
| 536 return true; | |
| 537 } | |
| 538 | |
| 539 std::string BufferedResourceLoader::GenerateHeaders( | |
| 540 int64 first_byte_position, | |
| 541 int64 last_byte_position) { | |
| 542 // Construct the value for the range header. | |
| 543 std::string header; | |
| 544 if (first_byte_position > kPositionNotSpecified && | |
| 545 last_byte_position > kPositionNotSpecified) { | |
| 546 if (first_byte_position <= last_byte_position) { | |
| 547 header = base::StringPrintf("bytes=%" PRId64 "-%" PRId64, | |
| 548 first_byte_position, | |
| 549 last_byte_position); | |
| 550 } | |
| 551 } else if (first_byte_position > kPositionNotSpecified) { | |
| 552 header = base::StringPrintf("bytes=%" PRId64 "-", | |
| 553 first_byte_position); | |
| 554 } else if (last_byte_position > kPositionNotSpecified) { | |
| 555 NOTIMPLEMENTED() << "Suffix range not implemented"; | |
| 556 } | |
| 557 return header; | |
| 558 } | |
| 559 | |
| 560 void BufferedResourceLoader::DoneRead(int error) { | |
| 561 read_callback_->RunWithParams(Tuple1<int>(error)); | |
| 562 read_callback_.reset(); | |
| 563 read_position_ = 0; | |
| 564 read_size_ = 0; | |
| 565 read_buffer_ = NULL; | |
| 566 first_offset_ = 0; | |
| 567 last_offset_ = 0; | |
| 568 } | |
| 569 | |
| 570 void BufferedResourceLoader::DoneStart(int error) { | |
| 571 start_callback_->RunWithParams(Tuple1<int>(error)); | |
| 572 start_callback_.reset(); | |
| 573 } | |
| 574 | |
| 575 void BufferedResourceLoader::NotifyNetworkEvent() { | |
| 576 if (event_callback_.get()) | |
| 577 event_callback_->Run(); | |
| 578 } | |
| 579 | |
| 580 } // namespace webkit_glue | |
| OLD | NEW |