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

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

Issue 14142: Start using the proxy resolve IPC for plugins.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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/webkit_glue.h ('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) 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 22 matching lines...) Expand all
33 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" 33 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
34 34
35 #include "base/message_loop.h" 35 #include "base/message_loop.h"
36 #include "base/ref_counted.h" 36 #include "base/ref_counted.h"
37 #include "base/thread.h" 37 #include "base/thread.h"
38 #include "base/waitable_event.h" 38 #include "base/waitable_event.h"
39 #include "net/base/cookie_monster.h" 39 #include "net/base/cookie_monster.h"
40 #include "net/base/io_buffer.h" 40 #include "net/base/io_buffer.h"
41 #include "net/base/net_util.h" 41 #include "net/base/net_util.h"
42 #include "net/base/upload_data.h" 42 #include "net/base/upload_data.h"
43 #include "net/proxy/proxy_service.h"
43 #include "net/url_request/url_request.h" 44 #include "net/url_request/url_request.h"
44 #include "webkit/glue/resource_loader_bridge.h" 45 #include "webkit/glue/resource_loader_bridge.h"
45 #include "webkit/tools/test_shell/test_shell_request_context.h" 46 #include "webkit/tools/test_shell/test_shell_request_context.h"
46 47
47 using webkit_glue::ResourceLoaderBridge; 48 using webkit_glue::ResourceLoaderBridge;
48 using net::HttpResponseHeaders; 49 using net::HttpResponseHeaders;
49 50
50 namespace { 51 namespace {
51 52
52 //----------------------------------------------------------------------------- 53 //-----------------------------------------------------------------------------
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 } 520 }
520 521
521 scoped_refptr<CookieGetter> getter = new CookieGetter(); 522 scoped_refptr<CookieGetter> getter = new CookieGetter();
522 523
523 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( 524 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
524 getter.get(), &CookieGetter::Get, url)); 525 getter.get(), &CookieGetter::Get, url));
525 526
526 return getter->GetResult(); 527 return getter->GetResult();
527 } 528 }
528 529
530 // Issue the proxy resolve request on the io thread, and wait
531 // for the result.
532 bool FindProxyForUrl(const GURL& url, std::string* proxy_list) {
533 DCHECK(request_context);
534
535 scoped_refptr<net::SyncProxyServiceHelper> sync_proxy_service(
536 new net::SyncProxyServiceHelper(io_thread->message_loop(),
537 request_context->proxy_service()));
538
539 net::ProxyInfo proxy_info;
540 int rv = sync_proxy_service->ResolveProxy(url, &proxy_info);
541 if (rv == net::OK) {
542 *proxy_list = proxy_info.GetAnnotatedProxyList();
543 }
544
545 return rv == net::OK;
546 }
547
529 } // namespace webkit_glue 548 } // namespace webkit_glue
530 549
531 //----------------------------------------------------------------------------- 550 //-----------------------------------------------------------------------------
532 551
533 // static 552 // static
534 void SimpleResourceLoaderBridge::Init(URLRequestContext* context) { 553 void SimpleResourceLoaderBridge::Init(URLRequestContext* context) {
535 // Make sure to stop any existing IO thread since it may be using the 554 // Make sure to stop any existing IO thread since it may be using the
536 // current request context. 555 // current request context.
537 Shutdown(); 556 Shutdown();
538 557
539 if (context) { 558 if (context) {
540 request_context = context; 559 request_context = context;
541 } else { 560 } else {
542 request_context = new TestShellRequestContext(); 561 request_context = new TestShellRequestContext();
543 } 562 }
544 request_context->AddRef(); 563 request_context->AddRef();
545 } 564 }
546 565
547 // static 566 // static
548 void SimpleResourceLoaderBridge::Shutdown() { 567 void SimpleResourceLoaderBridge::Shutdown() {
549 if (io_thread) { 568 if (io_thread) {
550 delete io_thread; 569 delete io_thread;
551 io_thread = NULL; 570 io_thread = NULL;
552 571
553 DCHECK(!request_context) << "should have been nulled by thread dtor"; 572 DCHECK(!request_context) << "should have been nulled by thread dtor";
554 } 573 }
555 } 574 }
556 575
OLDNEW
« no previous file with comments | « webkit/glue/webkit_glue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698