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

Side by Side Diff: webkit/tools/test_shell/simple_resource_loader_bridge.cc

Issue 6621006: Take out the is_content_filtered bool that gets passed around betwen renderer... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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
« no previous file with comments | « webkit/glue/weburlloader_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This file contains an implementation of the ResourceLoaderBridge class. 5 // This file contains an implementation of the ResourceLoaderBridge class.
6 // The class is implemented using net::URLRequest, meaning it is a "simple" 6 // The class is implemented using net::URLRequest, meaning it is a "simple"
7 // version that directly issues requests. The more complicated one used in the 7 // version that directly issues requests. The more complicated one used in the
8 // browser uses IPC. 8 // browser uses IPC.
9 // 9 //
10 // Because net::URLRequest only provides an asynchronous resource loading API, 10 // Because net::URLRequest only provides an asynchronous resource loading API,
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 &has_new_first_party_for_cookies, 243 &has_new_first_party_for_cookies,
244 &new_first_party_for_cookies)) { 244 &new_first_party_for_cookies)) {
245 g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( 245 g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
246 this, &RequestProxy::AsyncFollowDeferredRedirect, 246 this, &RequestProxy::AsyncFollowDeferredRedirect,
247 has_new_first_party_for_cookies, new_first_party_for_cookies)); 247 has_new_first_party_for_cookies, new_first_party_for_cookies));
248 } else { 248 } else {
249 Cancel(); 249 Cancel();
250 } 250 }
251 } 251 }
252 252
253 void NotifyReceivedResponse(const ResourceResponseInfo& info, 253 void NotifyReceivedResponse(const ResourceResponseInfo& info) {
254 bool content_filtered) {
255 if (peer_) 254 if (peer_)
256 peer_->OnReceivedResponse(info, content_filtered); 255 peer_->OnReceivedResponse(info);
257 } 256 }
258 257
259 void NotifyReceivedData(int bytes_read) { 258 void NotifyReceivedData(int bytes_read) {
260 if (!peer_) 259 if (!peer_)
261 return; 260 return;
262 261
263 // Make a local copy of buf_, since AsyncReadData reuses it. 262 // Make a local copy of buf_, since AsyncReadData reuses it.
264 scoped_array<char> buf_copy(new char[bytes_read]); 263 scoped_array<char> buf_copy(new char[bytes_read]);
265 memcpy(buf_copy.get(), buf_->data(), bytes_read); 264 memcpy(buf_copy.get(), buf_->data(), bytes_read);
266 265
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 virtual void OnReceivedRedirect( 394 virtual void OnReceivedRedirect(
396 const GURL& new_url, 395 const GURL& new_url,
397 const ResourceResponseInfo& info, 396 const ResourceResponseInfo& info,
398 bool* defer_redirect) { 397 bool* defer_redirect) {
399 *defer_redirect = true; // See AsyncFollowDeferredRedirect 398 *defer_redirect = true; // See AsyncFollowDeferredRedirect
400 owner_loop_->PostTask(FROM_HERE, NewRunnableMethod( 399 owner_loop_->PostTask(FROM_HERE, NewRunnableMethod(
401 this, &RequestProxy::NotifyReceivedRedirect, new_url, info)); 400 this, &RequestProxy::NotifyReceivedRedirect, new_url, info));
402 } 401 }
403 402
404 virtual void OnReceivedResponse( 403 virtual void OnReceivedResponse(
405 const ResourceResponseInfo& info, 404 const ResourceResponseInfo& info) {
406 bool content_filtered) {
407 owner_loop_->PostTask(FROM_HERE, NewRunnableMethod( 405 owner_loop_->PostTask(FROM_HERE, NewRunnableMethod(
408 this, &RequestProxy::NotifyReceivedResponse, info, content_filtered)); 406 this, &RequestProxy::NotifyReceivedResponse, info));
409 } 407 }
410 408
411 virtual void OnReceivedData(int bytes_read) { 409 virtual void OnReceivedData(int bytes_read) {
412 if (download_to_file_) { 410 if (download_to_file_) {
413 file_stream_.Write(buf_->data(), bytes_read, NULL); 411 file_stream_.Write(buf_->data(), bytes_read, NULL);
414 owner_loop_->PostTask(FROM_HERE, NewRunnableMethod( 412 owner_loop_->PostTask(FROM_HERE, NewRunnableMethod(
415 this, &RequestProxy::NotifyDownloadedData, bytes_read)); 413 this, &RequestProxy::NotifyDownloadedData, bytes_read));
416 return; 414 return;
417 } 415 }
418 416
(...skipping 23 matching lines...) Expand all
442 DCHECK(request->status().is_success()); 440 DCHECK(request->status().is_success());
443 ResourceResponseInfo info; 441 ResourceResponseInfo info;
444 PopulateResponseInfo(request, &info); 442 PopulateResponseInfo(request, &info);
445 OnReceivedRedirect(new_url, info, defer_redirect); 443 OnReceivedRedirect(new_url, info, defer_redirect);
446 } 444 }
447 445
448 virtual void OnResponseStarted(net::URLRequest* request) { 446 virtual void OnResponseStarted(net::URLRequest* request) {
449 if (request->status().is_success()) { 447 if (request->status().is_success()) {
450 ResourceResponseInfo info; 448 ResourceResponseInfo info;
451 PopulateResponseInfo(request, &info); 449 PopulateResponseInfo(request, &info);
452 OnReceivedResponse(info, false); 450 OnReceivedResponse(info);
453 AsyncReadData(); // start reading 451 AsyncReadData(); // start reading
454 } else { 452 } else {
455 Done(); 453 Done();
456 } 454 }
457 } 455 }
458 456
459 virtual void OnSSLCertificateError(net::URLRequest* request, 457 virtual void OnSSLCertificateError(net::URLRequest* request,
460 int cert_error, 458 int cert_error,
461 net::X509Certificate* cert) { 459 net::X509Certificate* cert) {
462 // Allow all certificate errors. 460 // Allow all certificate errors.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 // doing so requires API changes at all levels. Similar code exists in 585 // doing so requires API changes at all levels. Similar code exists in
588 // WebCore/platform/network/cf/ResourceHandleCFNet.cpp :-( 586 // WebCore/platform/network/cf/ResourceHandleCFNet.cpp :-(
589 if (new_url.GetOrigin() != result_->url.GetOrigin()) { 587 if (new_url.GetOrigin() != result_->url.GetOrigin()) {
590 DLOG(WARNING) << "Cross origin redirect denied"; 588 DLOG(WARNING) << "Cross origin redirect denied";
591 Cancel(); 589 Cancel();
592 return; 590 return;
593 } 591 }
594 result_->url = new_url; 592 result_->url = new_url;
595 } 593 }
596 594
597 virtual void OnReceivedResponse( 595 virtual void OnReceivedResponse(const ResourceResponseInfo& info) {
598 const ResourceResponseInfo& info,
599 bool content_filtered) {
600 *static_cast<ResourceResponseInfo*>(result_) = info; 596 *static_cast<ResourceResponseInfo*>(result_) = info;
601 } 597 }
602 598
603 virtual void OnReceivedData(int bytes_read) { 599 virtual void OnReceivedData(int bytes_read) {
604 if (download_to_file_) 600 if (download_to_file_)
605 file_stream_.Write(buf_->data(), bytes_read, NULL); 601 file_stream_.Write(buf_->data(), bytes_read, NULL);
606 else 602 else
607 result_->data.append(buf_->data(), bytes_read); 603 result_->data.append(buf_->data(), bytes_read);
608 AsyncReadData(); // read more (may recurse) 604 AsyncReadData(); // read more (may recurse)
609 } 605 }
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 915
920 // static 916 // static
921 scoped_refptr<base::MessageLoopProxy> 917 scoped_refptr<base::MessageLoopProxy>
922 SimpleResourceLoaderBridge::GetIoThread() { 918 SimpleResourceLoaderBridge::GetIoThread() {
923 if (!EnsureIOThread()) { 919 if (!EnsureIOThread()) {
924 LOG(DFATAL) << "Failed to create IO thread."; 920 LOG(DFATAL) << "Failed to create IO thread.";
925 return NULL; 921 return NULL;
926 } 922 }
927 return g_io_thread->message_loop_proxy(); 923 return g_io_thread->message_loop_proxy();
928 } 924 }
OLDNEW
« no previous file with comments | « webkit/glue/weburlloader_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698