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

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

Issue 9712: AppCachePlumbing (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 URLRequest, meaning it is a "simple" version 6 // The class is implemented using URLRequest, meaning it is a "simple" version
7 // that directly issues requests. The more complicated one used in the 7 // that directly issues requests. The more complicated one used in the
8 // browser uses IPC. 8 // browser uses IPC.
9 // 9 //
10 // Because URLRequest only provides an asynchronous resource loading API, this 10 // Because URLRequest only provides an asynchronous resource loading API, this
(...skipping 28 matching lines...) Expand all
39 #include "base/waitable_event.h" 39 #include "base/waitable_event.h"
40 #include "net/base/cookie_monster.h" 40 #include "net/base/cookie_monster.h"
41 #include "net/base/io_buffer.h" 41 #include "net/base/io_buffer.h"
42 #include "net/base/load_flags.h" 42 #include "net/base/load_flags.h"
43 #include "net/base/net_util.h" 43 #include "net/base/net_util.h"
44 #include "net/base/upload_data.h" 44 #include "net/base/upload_data.h"
45 #include "net/http/http_response_headers.h" 45 #include "net/http/http_response_headers.h"
46 #include "net/proxy/proxy_service.h" 46 #include "net/proxy/proxy_service.h"
47 #include "net/url_request/url_request.h" 47 #include "net/url_request/url_request.h"
48 #include "webkit/glue/resource_loader_bridge.h" 48 #include "webkit/glue/resource_loader_bridge.h"
49 #include "webkit/glue/webappcachecontext.h"
49 #include "webkit/tools/test_shell/test_shell_request_context.h" 50 #include "webkit/tools/test_shell/test_shell_request_context.h"
50 51
51 using webkit_glue::ResourceLoaderBridge; 52 using webkit_glue::ResourceLoaderBridge;
52 using net::HttpResponseHeaders; 53 using net::HttpResponseHeaders;
53 54
54 namespace { 55 namespace {
55 56
56 //----------------------------------------------------------------------------- 57 //-----------------------------------------------------------------------------
57 58
58 URLRequestContext* request_context = NULL; 59 URLRequestContext* request_context = NULL;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 93
93 //----------------------------------------------------------------------------- 94 //-----------------------------------------------------------------------------
94 95
95 struct RequestParams { 96 struct RequestParams {
96 std::string method; 97 std::string method;
97 GURL url; 98 GURL url;
98 GURL policy_url; 99 GURL policy_url;
99 GURL referrer; 100 GURL referrer;
100 std::string headers; 101 std::string headers;
101 int load_flags; 102 int load_flags;
103 int app_cache_context_id;
102 scoped_refptr<net::UploadData> upload; 104 scoped_refptr<net::UploadData> upload;
103 }; 105 };
104 106
105 // The interval for calls to RequestProxy::MaybeUpdateUploadProgress 107 // The interval for calls to RequestProxy::MaybeUpdateUploadProgress
106 static const int kUpdateUploadProgressIntervalMsec = 100; 108 static const int kUpdateUploadProgressIntervalMsec = 100;
107 109
108 // The RequestProxy does most of its work on the IO thread. The Start and 110 // The RequestProxy does most of its work on the IO thread. The Start and
109 // Cancel methods are proxied over to the IO thread, where an URLRequest object 111 // Cancel methods are proxied over to the IO thread, where an URLRequest object
110 // is instantiated. 112 // is instantiated.
111 class RequestProxy : public URLRequest::Delegate, 113 class RequestProxy : public URLRequest::Delegate,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 DCHECK(request->status().is_success()); 282 DCHECK(request->status().is_success());
281 OnReceivedRedirect(new_url); 283 OnReceivedRedirect(new_url);
282 } 284 }
283 285
284 virtual void OnResponseStarted(URLRequest* request) { 286 virtual void OnResponseStarted(URLRequest* request) {
285 if (request->status().is_success()) { 287 if (request->status().is_success()) {
286 ResourceLoaderBridge::ResponseInfo info; 288 ResourceLoaderBridge::ResponseInfo info;
287 info.request_time = request->request_time(); 289 info.request_time = request->request_time();
288 info.response_time = request->response_time(); 290 info.response_time = request->response_time();
289 info.headers = request->response_headers(); 291 info.headers = request->response_headers();
292 info.app_cache_id = WebAppCacheContext::kNoAppCacheId;
290 request->GetMimeType(&info.mime_type); 293 request->GetMimeType(&info.mime_type);
291 request->GetCharset(&info.charset); 294 request->GetCharset(&info.charset);
292 info.content_length = request->GetExpectedContentSize(); 295 info.content_length = request->GetExpectedContentSize();
293 OnReceivedResponse(info, false); 296 OnReceivedResponse(info, false);
294 AsyncReadData(); // start reading 297 AsyncReadData(); // start reading
295 } else { 298 } else {
296 Done(); 299 Done();
297 } 300 }
298 } 301 }
299 302
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 423
421 //----------------------------------------------------------------------------- 424 //-----------------------------------------------------------------------------
422 425
423 class ResourceLoaderBridgeImpl : public ResourceLoaderBridge { 426 class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
424 public: 427 public:
425 ResourceLoaderBridgeImpl(const std::string& method, 428 ResourceLoaderBridgeImpl(const std::string& method,
426 const GURL& url, 429 const GURL& url,
427 const GURL& policy_url, 430 const GURL& policy_url,
428 const GURL& referrer, 431 const GURL& referrer,
429 const std::string& headers, 432 const std::string& headers,
430 int load_flags) 433 int load_flags,
434 int app_cache_context_id)
431 : params_(new RequestParams), 435 : params_(new RequestParams),
432 proxy_(NULL) { 436 proxy_(NULL) {
433 params_->method = method; 437 params_->method = method;
434 params_->url = url; 438 params_->url = url;
435 params_->policy_url = policy_url; 439 params_->policy_url = policy_url;
436 params_->referrer = referrer; 440 params_->referrer = referrer;
437 params_->headers = headers; 441 params_->headers = headers;
438 params_->load_flags = load_flags; 442 params_->load_flags = load_flags;
443 params_->app_cache_context_id = app_cache_context_id;
439 } 444 }
440 445
441 virtual ~ResourceLoaderBridgeImpl() { 446 virtual ~ResourceLoaderBridgeImpl() {
442 if (proxy_) { 447 if (proxy_) {
443 proxy_->DropPeer(); 448 proxy_->DropPeer();
444 // Let the proxy die on the IO thread 449 // Let the proxy die on the IO thread
445 io_thread->message_loop()->ReleaseSoon(FROM_HERE, proxy_); 450 io_thread->message_loop()->ReleaseSoon(FROM_HERE, proxy_);
446 } 451 }
447 } 452 }
448 453
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 const GURL& url, 568 const GURL& url,
564 const GURL& policy_url, 569 const GURL& policy_url,
565 const GURL& referrer, 570 const GURL& referrer,
566 const std::string& frame_origin, 571 const std::string& frame_origin,
567 const std::string& main_frame_origin, 572 const std::string& main_frame_origin,
568 const std::string& headers, 573 const std::string& headers,
569 const std::string& default_mime_type, 574 const std::string& default_mime_type,
570 int load_flags, 575 int load_flags,
571 int requestor_pid, 576 int requestor_pid,
572 ResourceType::Type request_type, 577 ResourceType::Type request_type,
578 int app_cache_context_id,
573 int routing_id) { 579 int routing_id) {
574 return new ResourceLoaderBridgeImpl(method, url, policy_url, 580 return new ResourceLoaderBridgeImpl(method, url, policy_url,
575 referrer, headers, load_flags); 581 referrer, headers, load_flags,
582 app_cache_context_id);
576 } 583 }
577 584
578 // Issue the proxy resolve request on the io thread, and wait 585 // Issue the proxy resolve request on the io thread, and wait
579 // for the result. 586 // for the result.
580 bool FindProxyForUrl(const GURL& url, std::string* proxy_list) { 587 bool FindProxyForUrl(const GURL& url, std::string* proxy_list) {
581 DCHECK(request_context); 588 DCHECK(request_context);
582 589
583 scoped_refptr<net::SyncProxyServiceHelper> sync_proxy_service( 590 scoped_refptr<net::SyncProxyServiceHelper> sync_proxy_service(
584 new net::SyncProxyServiceHelper(io_thread->message_loop(), 591 new net::SyncProxyServiceHelper(io_thread->message_loop(),
585 request_context->proxy_service())); 592 request_context->proxy_service()));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 return std::string(); 651 return std::string();
645 } 652 }
646 653
647 scoped_refptr<CookieGetter> getter = new CookieGetter(); 654 scoped_refptr<CookieGetter> getter = new CookieGetter();
648 655
649 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( 656 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
650 getter.get(), &CookieGetter::Get, url)); 657 getter.get(), &CookieGetter::Get, url));
651 658
652 return getter->GetResult(); 659 return getter->GetResult();
653 } 660 }
OLDNEW
« webkit/glue/webframe.h ('K') | « webkit/glue/webresponse_impl.h ('k') | webkit/webkit.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698