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

Unified Diff: webkit/glue/media/simple_data_source.cc

Issue 5619002: Revert 68094 - Refactoring BufferedDataSource to work with WebURLLoader inste... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/media/simple_data_source.h ('k') | webkit/glue/media/simple_data_source_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/media/simple_data_source.cc
===================================================================
--- webkit/glue/media/simple_data_source.cc (revision 68125)
+++ webkit/glue/media/simple_data_source.cc (working copy)
@@ -7,10 +7,10 @@
#include "media/base/filter_host.h"
#include "net/base/load_flags.h"
#include "net/base/data_url.h"
+#include "net/http/http_response_headers.h"
#include "net/url_request/url_request_status.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h"
#include "webkit/glue/media/simple_data_source.h"
+#include "webkit/glue/resource_loader_bridge.h"
#include "webkit/glue/webkit_glue.h"
namespace {
@@ -30,13 +30,12 @@
SimpleDataSource::SimpleDataSource(
MessageLoop* render_loop,
- WebKit::WebFrame* frame)
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory)
: render_loop_(render_loop),
- frame_(frame),
+ bridge_factory_(bridge_factory),
size_(-1),
single_origin_(true),
- state_(UNINITIALIZED),
- keep_test_loader_(false) {
+ state_(UNINITIALIZED) {
DCHECK(render_loop);
}
@@ -109,59 +108,34 @@
return false;
}
-void SimpleDataSource::SetURLLoaderForTest(WebKit::WebURLLoader* mock_loader) {
- url_loader_.reset(mock_loader);
- keep_test_loader_ = true;
-}
-
-void SimpleDataSource::willSendRequest(
- WebKit::WebURLLoader* loader,
- WebKit::WebURLRequest& newRequest,
- const WebKit::WebURLResponse& redirectResponse) {
+bool SimpleDataSource::OnReceivedRedirect(
+ const GURL& new_url,
+ const webkit_glue::ResourceResponseInfo& info,
+ bool* has_new_first_party_for_cookies,
+ GURL* new_first_party_for_cookies) {
DCHECK(MessageLoop::current() == render_loop_);
- single_origin_ = url_.GetOrigin() == GURL(newRequest.url()).GetOrigin();
+ single_origin_ = url_.GetOrigin() == new_url.GetOrigin();
- url_ = newRequest.url();
+ // TODO(wtc): should we return a new first party for cookies URL?
+ *has_new_first_party_for_cookies = false;
+ return true;
}
-void SimpleDataSource::didSendData(
- WebKit::WebURLLoader* loader,
- unsigned long long bytesSent,
- unsigned long long totalBytesToBeSent) {
- NOTIMPLEMENTED();
-}
-
-void SimpleDataSource::didReceiveResponse(
- WebKit::WebURLLoader* loader,
- const WebKit::WebURLResponse& response) {
+void SimpleDataSource::OnReceivedResponse(
+ const webkit_glue::ResourceResponseInfo& info,
+ bool content_filtered) {
DCHECK(MessageLoop::current() == render_loop_);
- size_ = response.expectedContentLength();
+ size_ = info.content_length;
}
-void SimpleDataSource::didDownloadData(
- WebKit::WebURLLoader* loader,
- int dataLength) {
- NOTIMPLEMENTED();
-}
-
-void SimpleDataSource::didReceiveData(
- WebKit::WebURLLoader* loader,
- const char* data,
- int data_length) {
+void SimpleDataSource::OnReceivedData(const char* data, int len) {
DCHECK(MessageLoop::current() == render_loop_);
- data_.append(data, data_length);
+ data_.append(data, len);
}
-void SimpleDataSource::didReceiveCachedMetadata(
- WebKit::WebURLLoader* loader,
- const char* data,
- int dataLength) {
- NOTIMPLEMENTED();
-}
-
-void SimpleDataSource::didFinishLoading(
- WebKit::WebURLLoader* loader,
- double finishTime) {
+void SimpleDataSource::OnCompletedRequest(const URLRequestStatus& status,
+ const std::string& security_info,
+ const base::Time& completion_time) {
DCHECK(MessageLoop::current() == render_loop_);
AutoLock auto_lock(lock_);
// It's possible this gets called after Stop(), in which case |host_| is no
@@ -169,8 +143,10 @@
if (state_ == STOPPED)
return;
- // Otherwise we should be initializing and have created a WebURLLoader.
+ // Otherwise we should be initializing and have created a bridge.
DCHECK_EQ(state_, INITIALIZING);
+ DCHECK(bridge_.get());
+ bridge_.reset();
// If we don't get a content length or the request has failed, report it
// as a network error.
@@ -178,31 +154,9 @@
size_ = data_.length();
DCHECK(static_cast<size_t>(size_) == data_.length());
- DoneInitialization_Locked(true);
+ DoneInitialization_Locked(status.is_success());
}
-void SimpleDataSource::didFail(
- WebKit::WebURLLoader* loader,
- const WebKit::WebURLError& error) {
- DCHECK(MessageLoop::current() == render_loop_);
- AutoLock auto_lock(lock_);
- // It's possible this gets called after Stop(), in which case |host_| is no
- // longer valid.
- if (state_ == STOPPED)
- return;
-
- // Otherwise we should be initializing and have created a WebURLLoader.
- DCHECK_EQ(state_, INITIALIZING);
-
- // If we don't get a content length or the request has failed, report it
- // as a network error.
- if (size_ == -1)
- size_ = data_.length();
- DCHECK(static_cast<size_t>(size_) == data_.length());
-
- DoneInitialization_Locked(false);
-}
-
bool SimpleDataSource::HasSingleOrigin() {
DCHECK(MessageLoop::current() == render_loop_);
return single_origin_;
@@ -210,7 +164,7 @@
void SimpleDataSource::Abort() {
DCHECK(MessageLoop::current() == render_loop_);
- frame_ = NULL;
+ NOTIMPLEMENTED();
}
void SimpleDataSource::SetURL(const GURL& url) {
@@ -229,8 +183,6 @@
if (state_ == STOPPED)
return;
- CHECK(frame_);
-
DCHECK_EQ(state_, INITIALIZING);
if (IsDataProtocol(url_)) {
@@ -242,19 +194,10 @@
size_ = data_.length();
DoneInitialization_Locked(success);
} else {
- // Prepare the request.
- WebKit::WebURLRequest request(url_);
-
- frame_->setReferrerForRequest(request, WebKit::WebURL());
- // TODO(annacc): we should be using createAssociatedURLLoader() instead?
- frame_->dispatchWillSendRequest(request);
-
- // This flag is for unittests as we don't want to reset |url_loader|
- if (!keep_test_loader_)
- url_loader_.reset(WebKit::webKitClient()->createURLLoader());
-
- // Start the resource loading.
- url_loader_->loadAsynchronously(request, this);
+ // Create our bridge and start loading the resource.
+ bridge_.reset(bridge_factory_->CreateBridge(
+ url_, net::LOAD_BYPASS_CACHE, -1, -1));
+ bridge_->Start(this);
}
}
@@ -264,9 +207,9 @@
DCHECK_EQ(state_, STOPPED);
// Cancel any pending requests.
- if (url_loader_.get()) {
- url_loader_->cancel();
- url_loader_.reset();
+ if (bridge_.get()) {
+ bridge_->Cancel();
+ bridge_.reset();
}
}
« no previous file with comments | « webkit/glue/media/simple_data_source.h ('k') | webkit/glue/media/simple_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698