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

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

Issue 5756004: Separate BufferedDataSource and BufferedResourceLoader into two files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removing the constants and methods I added to http_util.h 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/process_util.h" 6 #include "base/process_util.h"
7 #include "media/base/filter_host.h" 7 #include "media/base/filter_host.h"
8 #include "net/base/data_url.h"
8 #include "net/base/load_flags.h" 9 #include "net/base/load_flags.h"
9 #include "net/base/data_url.h"
10 #include "net/url_request/url_request_status.h" 10 #include "net/url_request/url_request_status.h"
11 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" 11 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" 12 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h"
13 #include "webkit/glue/media/simple_data_source.h" 13 #include "webkit/glue/media/simple_data_source.h"
14 #include "webkit/glue/webkit_glue.h" 14 #include "webkit/glue/webkit_glue.h"
15 15
16 namespace { 16 namespace {
17 17
18 const char kHttpScheme[] = "http";
19 const char kHttpsScheme[] = "https";
20 const char kDataScheme[] = "data"; 18 const char kDataScheme[] = "data";
21 19
22 // A helper method that accepts only HTTP, HTTPS and FILE protocol. 20 // A helper method that accepts only HTTP, HTTPS and FILE protocol.
23 bool IsDataProtocol(const GURL& url) { 21 bool IsDataProtocol(const GURL& url) {
24 return url.SchemeIs(kDataScheme); 22 return url.SchemeIs(kDataScheme);
25 } 23 }
26 24
27 } // namespace 25 } // namespace
28 26
29 namespace webkit_glue { 27 namespace webkit_glue {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 bool success = net::DataURL::Parse(url_, &mime_type, &charset, &data_); 237 bool success = net::DataURL::Parse(url_, &mime_type, &charset, &data_);
240 238
241 // Don't care about the mime-type just proceed if decoding was successful. 239 // Don't care about the mime-type just proceed if decoding was successful.
242 size_ = data_.length(); 240 size_ = data_.length();
243 DoneInitialization_Locked(success); 241 DoneInitialization_Locked(success);
244 } else { 242 } else {
245 // Prepare the request. 243 // Prepare the request.
246 WebKit::WebURLRequest request(url_); 244 WebKit::WebURLRequest request(url_);
247 245
248 frame_->setReferrerForRequest(request, WebKit::WebURL()); 246 frame_->setReferrerForRequest(request, WebKit::WebURL());
249 // TODO(annacc): we should be using createAssociatedURLLoader() instead?
250 frame_->dispatchWillSendRequest(request);
251 247
252 // This flag is for unittests as we don't want to reset |url_loader| 248 // This flag is for unittests as we don't want to reset |url_loader|
253 if (!keep_test_loader_) 249 if (!keep_test_loader_)
254 url_loader_.reset(WebKit::webKitClient()->createURLLoader()); 250 url_loader_.reset(frame_->createAssociatedURLLoader());
255 251
256 // Start the resource loading. 252 // Start the resource loading.
257 url_loader_->loadAsynchronously(request, this); 253 url_loader_->loadAsynchronously(request, this);
258 } 254 }
259 } 255 }
260 256
261 void SimpleDataSource::CancelTask() { 257 void SimpleDataSource::CancelTask() {
262 DCHECK(MessageLoop::current() == render_loop_); 258 DCHECK(MessageLoop::current() == render_loop_);
263 AutoLock auto_lock(lock_); 259 AutoLock auto_lock(lock_);
264 DCHECK_EQ(state_, STOPPED); 260 DCHECK_EQ(state_, STOPPED);
(...skipping 14 matching lines...) Expand all
279 // If scheme is file or data, say we are loaded. 275 // If scheme is file or data, say we are loaded.
280 host()->SetLoaded(url_.SchemeIsFile() || IsDataProtocol(url_)); 276 host()->SetLoaded(url_.SchemeIsFile() || IsDataProtocol(url_));
281 } else { 277 } else {
282 host()->SetError(media::PIPELINE_ERROR_NETWORK); 278 host()->SetError(media::PIPELINE_ERROR_NETWORK);
283 } 279 }
284 initialize_callback_->Run(); 280 initialize_callback_->Run();
285 initialize_callback_.reset(); 281 initialize_callback_.reset();
286 } 282 }
287 283
288 } // namespace webkit_glue 284 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698