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

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

Issue 9078003: Poll PAC scripts for content changes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix dcheck reached on bot Created 8 years, 11 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
« no previous file with comments | « net/proxy/mock_proxy_script_fetcher.h ('k') | net/proxy/proxy_resolver_script_data.h » ('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) 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 #include "net/proxy/mock_proxy_script_fetcher.h" 5 #include "net/proxy/mock_proxy_script_fetcher.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h"
8 #include "base/string16.h" 9 #include "base/string16.h"
9 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
10 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
11 12
12 namespace net { 13 namespace net {
13 14
14 MockProxyScriptFetcher::MockProxyScriptFetcher() 15 MockProxyScriptFetcher::MockProxyScriptFetcher()
15 : pending_request_text_(NULL) { 16 : pending_request_text_(NULL),
17 waiting_for_fetch_(false) {
16 } 18 }
17 19
18 MockProxyScriptFetcher::~MockProxyScriptFetcher() {} 20 MockProxyScriptFetcher::~MockProxyScriptFetcher() {}
19 21
20 // ProxyScriptFetcher implementation. 22 // ProxyScriptFetcher implementation.
21 int MockProxyScriptFetcher::Fetch(const GURL& url, string16* text, 23 int MockProxyScriptFetcher::Fetch(const GURL& url, string16* text,
22 const CompletionCallback& callback) { 24 const CompletionCallback& callback) {
23 DCHECK(!has_pending_request()); 25 DCHECK(!has_pending_request());
24 26
25 // Save the caller's information, and have them wait. 27 // Save the caller's information, and have them wait.
26 pending_request_url_ = url; 28 pending_request_url_ = url;
27 pending_request_callback_ = callback; 29 pending_request_callback_ = callback;
28 pending_request_text_ = text; 30 pending_request_text_ = text;
31
32 if (waiting_for_fetch_)
33 MessageLoop::current()->Quit();
34
29 return ERR_IO_PENDING; 35 return ERR_IO_PENDING;
30 } 36 }
31 37
32 void MockProxyScriptFetcher::NotifyFetchCompletion( 38 void MockProxyScriptFetcher::NotifyFetchCompletion(
33 int result, const std::string& ascii_text) { 39 int result, const std::string& ascii_text) {
34 DCHECK(has_pending_request()); 40 DCHECK(has_pending_request());
35 *pending_request_text_ = ASCIIToUTF16(ascii_text); 41 *pending_request_text_ = ASCIIToUTF16(ascii_text);
36 CompletionCallback callback = pending_request_callback_; 42 CompletionCallback callback = pending_request_callback_;
37 pending_request_callback_.Reset(); 43 pending_request_callback_.Reset();
38 callback.Run(result); 44 callback.Run(result);
39 } 45 }
40 46
41 void MockProxyScriptFetcher::Cancel() { 47 void MockProxyScriptFetcher::Cancel() {
42 } 48 }
43 49
44 URLRequestContext* MockProxyScriptFetcher::GetRequestContext() const { 50 URLRequestContext* MockProxyScriptFetcher::GetRequestContext() const {
45 return NULL; 51 return NULL;
46 } 52 }
47 53
48 const GURL& MockProxyScriptFetcher::pending_request_url() const { 54 const GURL& MockProxyScriptFetcher::pending_request_url() const {
49 return pending_request_url_; 55 return pending_request_url_;
50 } 56 }
51 57
52 bool MockProxyScriptFetcher::has_pending_request() const { 58 bool MockProxyScriptFetcher::has_pending_request() const {
53 return !pending_request_callback_.is_null(); 59 return !pending_request_callback_.is_null();
54 } 60 }
55 61
62 void MockProxyScriptFetcher::WaitUntilFetch() {
63 DCHECK(!has_pending_request());
64 waiting_for_fetch_ = true;
65 MessageLoop::current()->Run();
66 waiting_for_fetch_ = false;
67 }
68
56 } // namespace net 69 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/mock_proxy_script_fetcher.h ('k') | net/proxy/proxy_resolver_script_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698