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

Side by Side Diff: webkit/glue/media/buffered_resource_loader.cc

Issue 7591001: Log BufferedResourceLoader events to MediaLog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "webkit/glue/media/buffered_resource_loader.h" 5 #include "webkit/glue/media/buffered_resource_loader.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "media/base/media_log.h"
10 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
11 #include "net/http/http_request_headers.h" 12 #include "net/http/http_request_headers.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderOptions.h " 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderOptions.h "
17 #include "webkit/glue/multipart_response_delegate.h" 18 #include "webkit/glue/multipart_response_delegate.h"
18 #include "webkit/glue/webkit_glue.h" 19 #include "webkit/glue/webkit_glue.h"
19 20
(...skipping 27 matching lines...) Expand all
47 48
48 // Maximum number of bytes outside the buffer we will wait for in order to 49 // Maximum number of bytes outside the buffer we will wait for in order to
49 // fulfill a read. If a read starts more than 2MB away from the data we 50 // fulfill a read. If a read starts more than 2MB away from the data we
50 // currently have in the buffer, we will not wait for buffer to reach the read's 51 // currently have in the buffer, we will not wait for buffer to reach the read's
51 // location and will instead reset the request. 52 // location and will instead reset the request.
52 static const int kForwardWaitThreshold = 2 * kMegabyte; 53 static const int kForwardWaitThreshold = 2 * kMegabyte;
53 54
54 BufferedResourceLoader::BufferedResourceLoader( 55 BufferedResourceLoader::BufferedResourceLoader(
55 const GURL& url, 56 const GURL& url,
56 int64 first_byte_position, 57 int64 first_byte_position,
57 int64 last_byte_position) 58 int64 last_byte_position,
59 media::MediaLog* media_log)
58 : buffer_(new media::SeekableBuffer(kBackwardCapacity, kForwardCapacity)), 60 : buffer_(new media::SeekableBuffer(kBackwardCapacity, kForwardCapacity)),
59 deferred_(false), 61 deferred_(false),
60 defer_strategy_(kReadThenDefer), 62 defer_strategy_(kReadThenDefer),
61 completed_(false), 63 completed_(false),
62 range_requested_(false), 64 range_requested_(false),
63 range_supported_(false), 65 range_supported_(false),
64 saved_forward_capacity_(0), 66 saved_forward_capacity_(0),
65 url_(url), 67 url_(url),
66 first_byte_position_(first_byte_position), 68 first_byte_position_(first_byte_position),
67 last_byte_position_(last_byte_position), 69 last_byte_position_(last_byte_position),
68 single_origin_(true), 70 single_origin_(true),
69 start_callback_(NULL), 71 start_callback_(NULL),
70 offset_(0), 72 offset_(0),
71 content_length_(kPositionNotSpecified), 73 content_length_(kPositionNotSpecified),
72 instance_size_(kPositionNotSpecified), 74 instance_size_(kPositionNotSpecified),
73 read_callback_(NULL), 75 read_callback_(NULL),
74 read_position_(0), 76 read_position_(0),
75 read_size_(0), 77 read_size_(0),
76 read_buffer_(NULL), 78 read_buffer_(NULL),
77 first_offset_(0), 79 first_offset_(0),
78 last_offset_(0), 80 last_offset_(0),
79 keep_test_loader_(false) { 81 keep_test_loader_(false),
82 media_log_(media_log) {
80 } 83 }
81 84
82 BufferedResourceLoader::~BufferedResourceLoader() { 85 BufferedResourceLoader::~BufferedResourceLoader() {
83 if (!completed_ && url_loader_.get()) 86 if (!completed_ && url_loader_.get())
84 url_loader_->cancel(); 87 url_loader_->cancel();
85 } 88 }
86 89
87 void BufferedResourceLoader::Start(net::CompletionCallback* start_callback, 90 void BufferedResourceLoader::Start(net::CompletionCallback* start_callback,
88 NetworkEventCallback* event_callback, 91 NetworkEventCallback* event_callback,
89 WebFrame* frame) { 92 WebFrame* frame) {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 // Consume excess bytes from our in-memory buffer if necessary. 395 // Consume excess bytes from our in-memory buffer if necessary.
393 if (buffer_->forward_bytes() > buffer_->forward_capacity()) { 396 if (buffer_->forward_bytes() > buffer_->forward_capacity()) {
394 size_t excess = buffer_->forward_bytes() - buffer_->forward_capacity(); 397 size_t excess = buffer_->forward_bytes() - buffer_->forward_capacity();
395 bool success = buffer_->Seek(excess); 398 bool success = buffer_->Seek(excess);
396 DCHECK(success); 399 DCHECK(success);
397 offset_ += first_offset_ + excess; 400 offset_ += first_offset_ + excess;
398 } 401 }
399 402
400 // Notify that we have received some data. 403 // Notify that we have received some data.
401 NotifyNetworkEvent(); 404 NotifyNetworkEvent();
405 Log();
402 } 406 }
403 407
404 void BufferedResourceLoader::didDownloadData( 408 void BufferedResourceLoader::didDownloadData(
405 WebKit::WebURLLoader* loader, 409 WebKit::WebURLLoader* loader,
406 int dataLength) { 410 int dataLength) {
407 NOTIMPLEMENTED(); 411 NOTIMPLEMENTED();
408 } 412 }
409 413
410 void BufferedResourceLoader::didReceiveCachedMetadata( 414 void BufferedResourceLoader::didReceiveCachedMetadata(
411 WebURLLoader* loader, 415 WebURLLoader* loader,
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 read_callback_.reset(); 674 read_callback_.reset();
671 if (buffer_.get() && saved_forward_capacity_) { 675 if (buffer_.get() && saved_forward_capacity_) {
672 buffer_->set_forward_capacity(saved_forward_capacity_); 676 buffer_->set_forward_capacity(saved_forward_capacity_);
673 saved_forward_capacity_ = 0; 677 saved_forward_capacity_ = 0;
674 } 678 }
675 read_position_ = 0; 679 read_position_ = 0;
676 read_size_ = 0; 680 read_size_ = 0;
677 read_buffer_ = NULL; 681 read_buffer_ = NULL;
678 first_offset_ = 0; 682 first_offset_ = 0;
679 last_offset_ = 0; 683 last_offset_ = 0;
684 Log();
680 } 685 }
681 686
682 void BufferedResourceLoader::DoneStart(int error) { 687 void BufferedResourceLoader::DoneStart(int error) {
683 start_callback_->RunWithParams(Tuple1<int>(error)); 688 start_callback_->RunWithParams(Tuple1<int>(error));
684 start_callback_.reset(); 689 start_callback_.reset();
685 } 690 }
686 691
687 void BufferedResourceLoader::NotifyNetworkEvent() { 692 void BufferedResourceLoader::NotifyNetworkEvent() {
688 if (event_callback_.get()) 693 if (event_callback_.get())
689 event_callback_->Run(); 694 event_callback_->Run();
690 } 695 }
691 696
692 bool BufferedResourceLoader::IsRangeRequest() const { 697 bool BufferedResourceLoader::IsRangeRequest() const {
693 return first_byte_position_ != kPositionNotSpecified; 698 return first_byte_position_ != kPositionNotSpecified;
694 } 699 }
695 700
701 void BufferedResourceLoader::Log() {
702 if (buffer_.get()) {
scherkus (not reviewing) 2011/08/08 23:18:25 so is media_log a required param or not? if it's
Scott Franklin 2011/08/09 00:27:27 That's a check for buffer_, which is null surprisi
703 media_log_->SetBufferedExtents(offset_ - buffer_->backward_bytes(),
704 offset_,
705 offset_ + buffer_->forward_bytes());
706 }
707 }
708
696 } // namespace webkit_glue 709 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698