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

Side by Side Diff: net/proxy/proxy_resolver_v8.cc

Issue 125107: * Move the global "DnsResolutionObserver" code depended on by DNS prefetcher,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address jar's comments Created 11 years, 6 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/net.gyp ('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) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "net/proxy/proxy_resolver_v8.h" 5 #include "net/proxy/proxy_resolver_v8.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/waitable_event.h" 10 #include "base/waitable_event.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 MessageLoop* host_resolver_loop) 63 MessageLoop* host_resolver_loop)
64 : host_resolver_(host_resolver), 64 : host_resolver_(host_resolver),
65 host_resolver_loop_(host_resolver_loop), 65 host_resolver_loop_(host_resolver_loop),
66 event_(false, false), 66 event_(false, false),
67 ALLOW_THIS_IN_INITIALIZER_LIST( 67 ALLOW_THIS_IN_INITIALIZER_LIST(
68 callback_(this, &SyncHostResolverBridge::OnResolveCompletion)) { 68 callback_(this, &SyncHostResolverBridge::OnResolveCompletion)) {
69 } 69 }
70 70
71 // Run the resolve on host_resolver_loop, and wait for result. 71 // Run the resolve on host_resolver_loop, and wait for result.
72 int Resolve(const std::string& hostname, net::AddressList* addresses) { 72 int Resolve(const std::string& hostname, net::AddressList* addresses) {
73 int kPort = 80; // Doesn't matter. 73 // Port number doesn't matter.
74 HostResolver::RequestInfo info(hostname, 80);
74 75
75 // Hack for tests -- run synchronously on current thread. 76 // Hack for tests -- run synchronously on current thread.
76 if (!host_resolver_loop_) 77 if (!host_resolver_loop_)
77 return host_resolver_->Resolve(hostname, kPort, addresses, NULL, NULL); 78 return host_resolver_->Resolve(info, addresses, NULL, NULL);
78 79
79 // Otherwise start an async resolve on the resolver's thread. 80 // Otherwise start an async resolve on the resolver's thread.
80 host_resolver_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, 81 host_resolver_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
81 &SyncHostResolverBridge::StartResolve, hostname, kPort, addresses)); 82 &SyncHostResolverBridge::StartResolve, info, addresses));
82 83
83 // Wait for the resolve to complete in the resolver's thread. 84 // Wait for the resolve to complete in the resolver's thread.
84 event_.Wait(); 85 event_.Wait();
85 return err_; 86 return err_;
86 } 87 }
87 88
88 private: 89 private:
89 // Called on host_resolver_loop_. 90 // Called on host_resolver_loop_.
90 void StartResolve(const std::string& hostname, 91 void StartResolve(const HostResolver::RequestInfo& info,
91 int port,
92 net::AddressList* addresses) { 92 net::AddressList* addresses) {
93 DCHECK_EQ(host_resolver_loop_, MessageLoop::current()); 93 DCHECK_EQ(host_resolver_loop_, MessageLoop::current());
94 int error = host_resolver_->Resolve( 94 int error = host_resolver_->Resolve(info, addresses, &callback_, NULL);
95 hostname, port, addresses, &callback_, NULL);
96 if (error != ERR_IO_PENDING) 95 if (error != ERR_IO_PENDING)
97 OnResolveCompletion(error); // Completed synchronously. 96 OnResolveCompletion(error); // Completed synchronously.
98 } 97 }
99 98
100 // Called on host_resolver_loop_. 99 // Called on host_resolver_loop_.
101 void OnResolveCompletion(int result) { 100 void OnResolveCompletion(int result) {
102 DCHECK_EQ(host_resolver_loop_, MessageLoop::current()); 101 DCHECK_EQ(host_resolver_loop_, MessageLoop::current());
103 err_ = result; 102 err_ = result;
104 event_.Signal(); 103 event_.Signal();
105 } 104 }
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 context_.reset(new Context(js_bindings_.get(), data)); 367 context_.reset(new Context(js_bindings_.get(), data));
369 } 368 }
370 369
371 // static 370 // static
372 ProxyResolverV8::JSBindings* ProxyResolverV8::CreateDefaultBindings( 371 ProxyResolverV8::JSBindings* ProxyResolverV8::CreateDefaultBindings(
373 HostResolver* host_resolver, MessageLoop* host_resolver_loop) { 372 HostResolver* host_resolver, MessageLoop* host_resolver_loop) {
374 return new DefaultJSBindings(host_resolver, host_resolver_loop); 373 return new DefaultJSBindings(host_resolver, host_resolver_loop);
375 } 374 }
376 375
377 } // namespace net 376 } // namespace net
OLDNEW
« no previous file with comments | « net/net.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698