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

Unified Diff: net/url_request/url_request_simple_job.cc

Issue 104513002: Fixed playing video in component extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Linux compilation fix. Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_simple_job.h ('k') | net/url_request/url_request_simple_job_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_simple_job.cc
diff --git a/net/url_request/url_request_simple_job.cc b/net/url_request/url_request_simple_job.cc
index bd945557e3de2f5edd0b71b4c5fbf9839409a2d6..f266e3b505d05ea37b7e237ce91e8dbc472c0937 100644
--- a/net/url_request/url_request_simple_job.cc
+++ b/net/url_request/url_request_simple_job.cc
@@ -4,18 +4,22 @@
#include "net/url_request/url_request_simple_job.h"
+#include <vector>
+
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop/message_loop.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
+#include "net/http/http_request_headers.h"
+#include "net/http/http_util.h"
#include "net/url_request/url_request_status.h"
namespace net {
URLRequestSimpleJob::URLRequestSimpleJob(
URLRequest* request, NetworkDelegate* network_delegate)
- : URLRequestJob(request, network_delegate),
+ : URLRangeRequestJob(request, network_delegate),
data_offset_(0),
weak_factory_(this) {}
@@ -42,7 +46,7 @@ URLRequestSimpleJob::~URLRequestSimpleJob() {}
bool URLRequestSimpleJob::ReadRawData(IOBuffer* buf, int buf_size,
int* bytes_read) {
DCHECK(bytes_read);
- int remaining = static_cast<int>(data_.size()) - data_offset_;
+ int remaining = byte_range_.last_byte_position() - data_offset_ + 1;
if (buf_size > remaining)
buf_size = remaining;
memcpy(buf->data(), data_.data() + data_offset_, buf_size);
@@ -55,6 +59,15 @@ void URLRequestSimpleJob::StartAsync() {
if (!request_)
return;
+ if (ranges().size() > 1) {
+ NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
+ ERR_REQUEST_RANGE_NOT_SATISFIABLE));
+ return;
+ }
+
+ if (!ranges().empty() && range_parse_result() == OK)
+ byte_range_ = ranges().front();
+
int result = GetData(&mime_type_, &charset_, &data_,
base::Bind(&URLRequestSimpleJob::OnGetDataCompleted,
weak_factory_.GetWeakPtr()));
@@ -65,6 +78,16 @@ void URLRequestSimpleJob::StartAsync() {
void URLRequestSimpleJob::OnGetDataCompleted(int result) {
if (result == OK) {
// Notify that the headers are complete
+ if (!byte_range_.ComputeBounds(data_.size())) {
+ NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
+ ERR_REQUEST_RANGE_NOT_SATISFIABLE));
+ return;
+ }
+
+ data_offset_ = byte_range_.first_byte_position();
+ int remaining_bytes = byte_range_.last_byte_position() -
+ byte_range_.first_byte_position() + 1;
+ set_expected_content_size(remaining_bytes);
NotifyHeadersComplete();
} else {
NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result));
« no previous file with comments | « net/url_request/url_request_simple_job.h ('k') | net/url_request/url_request_simple_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698