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

Side by Side Diff: net/proxy/proxy_service.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 | « net/proxy/proxy_service.h ('k') | webkit/glue/plugins/mozilla_extensions.cc » ('j') | 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 #include "net/proxy/proxy_service.h" 5 #include "net/proxy/proxy_service.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <winhttp.h> 9 #include <winhttp.h>
10 #endif 10 #endif
11 11
12 #include <algorithm> 12 #include <algorithm>
13 13
14 #include "base/compiler_specific.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/message_loop.h" 16 #include "base/message_loop.h"
16 #include "base/string_tokenizer.h" 17 #include "base/string_tokenizer.h"
17 #include "base/string_util.h" 18 #include "base/string_util.h"
18 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
19 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
20 #include "net/proxy/proxy_config_service_fixed.h" 21 #include "net/proxy/proxy_config_service_fixed.h"
21 #if defined(OS_WIN) 22 #if defined(OS_WIN)
22 #include "net/proxy/proxy_config_service_win.h" 23 #include "net/proxy/proxy_config_service_win.h"
23 #include "net/proxy/proxy_resolver_winhttp.h" 24 #include "net/proxy/proxy_resolver_winhttp.h"
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 516
516 url_domain += url.host(); 517 url_domain += url.host();
517 // This isn't superfluous; GURL case canonicalization doesn't hit the embedded 518 // This isn't superfluous; GURL case canonicalization doesn't hit the embedded
518 // percent-encoded characters. 519 // percent-encoded characters.
519 StringToLowerASCII(&url_domain); 520 StringToLowerASCII(&url_domain);
520 521
521 if (config_.proxy_bypass_local_names) { 522 if (config_.proxy_bypass_local_names) {
522 if (url.host().find('.') == std::string::npos) 523 if (url.host().find('.') == std::string::npos)
523 return true; 524 return true;
524 } 525 }
525 526
526 for(std::vector<std::string>::const_iterator i = config_.proxy_bypass.begin(); 527 for(std::vector<std::string>::const_iterator i = config_.proxy_bypass.begin();
527 i != config_.proxy_bypass.end(); ++i) { 528 i != config_.proxy_bypass.end(); ++i) {
528 std::string bypass_url_domain = *i; 529 std::string bypass_url_domain = *i;
529 530
530 // The proxy server bypass list can contain entities with http/https 531 // The proxy server bypass list can contain entities with http/https
531 // If no scheme is specified then it indicates that all schemes are 532 // If no scheme is specified then it indicates that all schemes are
532 // allowed for the current entry. For matching this we just use 533 // allowed for the current entry. For matching this we just use
533 // the protocol scheme of the url passed in. 534 // the protocol scheme of the url passed in.
534 if (bypass_url_domain.find("://") == std::string::npos) { 535 if (bypass_url_domain.find("://") == std::string::npos) {
535 std::string bypass_url_domain_with_scheme = url.scheme(); 536 std::string bypass_url_domain_with_scheme = url.scheme();
536 bypass_url_domain_with_scheme += "://"; 537 bypass_url_domain_with_scheme += "://";
537 bypass_url_domain_with_scheme += bypass_url_domain; 538 bypass_url_domain_with_scheme += bypass_url_domain;
538 539
539 bypass_url_domain = bypass_url_domain_with_scheme; 540 bypass_url_domain = bypass_url_domain_with_scheme;
540 } 541 }
541 542
542 StringToLowerASCII(&bypass_url_domain); 543 StringToLowerASCII(&bypass_url_domain);
543 544
544 if (MatchPattern(url_domain, bypass_url_domain)) 545 if (MatchPattern(url_domain, bypass_url_domain))
545 return true; 546 return true;
546 547
547 // Some systems (the Mac, for example) allow CIDR-style specification of 548 // Some systems (the Mac, for example) allow CIDR-style specification of
548 // proxy bypass for IP-specified hosts (e.g. "10.0.0.0/8"; see 549 // proxy bypass for IP-specified hosts (e.g. "10.0.0.0/8"; see
549 // http://www.tcd.ie/iss/internet/osx_proxy.php for a real-world example). 550 // http://www.tcd.ie/iss/internet/osx_proxy.php for a real-world example).
550 // That's kinda cool so we'll provide that for everyone. 551 // That's kinda cool so we'll provide that for everyone.
551 // TODO(avi): implement here 552 // TODO(avi): implement here
552 } 553 }
553 554
554 return false; 555 return false;
555 } 556 }
556 557
558 SyncProxyServiceHelper::SyncProxyServiceHelper(MessageLoop* io_message_loop,
559 ProxyService* proxy_service)
560 : io_message_loop_(io_message_loop),
561 proxy_service_(proxy_service),
562 event_(false, false),
563 ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
564 this, &SyncProxyServiceHelper::OnCompletion)) {
565 DCHECK(io_message_loop_ != MessageLoop::current());
566 }
567
568 int SyncProxyServiceHelper::ResolveProxy(const GURL& url,
569 ProxyInfo* proxy_info) {
570 DCHECK(io_message_loop_ != MessageLoop::current());
571
572 io_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
573 this, &SyncProxyServiceHelper::StartAsyncResolve, url));
574
575 event_.Wait();
576
577 if (result_ == net::OK) {
578 *proxy_info = proxy_info_;
579 }
580 return result_;
581 }
582
583 int SyncProxyServiceHelper::ReconsiderProxyAfterError(const GURL& url,
584 ProxyInfo* proxy_info) {
585 DCHECK(io_message_loop_ != MessageLoop::current());
586
587 io_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
588 this, &SyncProxyServiceHelper::StartAsyncReconsider, url));
589
590 event_.Wait();
591
592 if (result_ == net::OK) {
593 *proxy_info = proxy_info_;
594 }
595 return result_;
596 }
597
598 void SyncProxyServiceHelper::StartAsyncResolve(const GURL& url) {
599 result_ = proxy_service_->ResolveProxy(url, &proxy_info_, &callback_, NULL);
600 if (result_ != net::ERR_IO_PENDING) {
601 OnCompletion(result_);
602 }
603 }
604
605 void SyncProxyServiceHelper::StartAsyncReconsider(const GURL& url) {
606 result_ = proxy_service_->ReconsiderProxyAfterError(
607 url, &proxy_info_, &callback_, NULL);
608 if (result_ != net::ERR_IO_PENDING) {
609 OnCompletion(result_);
610 }
611 }
612
613 void SyncProxyServiceHelper::OnCompletion(int rv) {
614 result_ = rv;
615 event_.Signal();
616 }
617
557 } // namespace net 618 } // namespace net
558 619
OLDNEW
« no previous file with comments | « net/proxy/proxy_service.h ('k') | webkit/glue/plugins/mozilla_extensions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698