OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_script_fetcher.h" | 5 #include "net/proxy/proxy_script_fetcher.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 fetcher_(NULL), | 55 fetcher_(NULL), |
56 ALLOW_THIS_IN_INITIALIZER_LIST( | 56 ALLOW_THIS_IN_INITIALIZER_LIST( |
57 callback_(this, &SynchFetcherThreadHelper::OnFetchCompletion)) { | 57 callback_(this, &SynchFetcherThreadHelper::OnFetchCompletion)) { |
58 url_request_context_ = new RequestContext; | 58 url_request_context_ = new RequestContext; |
59 fetcher_.reset(net::ProxyScriptFetcher::Create(url_request_context_.get())); | 59 fetcher_.reset(net::ProxyScriptFetcher::Create(url_request_context_.get())); |
60 } | 60 } |
61 | 61 |
62 // Starts fetching the script at |url|. Upon completion |event_| will be | 62 // Starts fetching the script at |url|. Upon completion |event_| will be |
63 // signalled, and the bytes read will have been written to |fetch_result_|. | 63 // signalled, and the bytes read will have been written to |fetch_result_|. |
64 void Start(const GURL& url) { | 64 void Start(const GURL& url) { |
65 fetcher_->Fetch(url, &fetch_result_->bytes, &callback_); | 65 int rv = fetcher_->Fetch(url, &fetch_result_->bytes, &callback_); |
| 66 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
66 } | 67 } |
67 | 68 |
68 void OnFetchCompletion(int result) { | 69 void OnFetchCompletion(int result) { |
69 fetch_result_->code = result; | 70 fetch_result_->code = result; |
70 event_->Signal(); | 71 event_->Signal(); |
71 } | 72 } |
72 | 73 |
73 private: | 74 private: |
74 base::WaitableEvent* event_; | 75 base::WaitableEvent* event_; |
75 FetchResult* fetch_result_; | 76 FetchResult* fetch_result_; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 329 |
329 { // Make sure we can still fetch regular URLs. | 330 { // Make sure we can still fetch regular URLs. |
330 GURL url = server->TestServerPage("files/pac.nsproxy"); | 331 GURL url = server->TestServerPage("files/pac.nsproxy"); |
331 FetchResult result = pac_fetcher.Fetch(url); | 332 FetchResult result = pac_fetcher.Fetch(url); |
332 EXPECT_EQ(net::OK, result.code); | 333 EXPECT_EQ(net::OK, result.code); |
333 EXPECT_EQ("-pac.nsproxy-\n", result.bytes); | 334 EXPECT_EQ("-pac.nsproxy-\n", result.bytes); |
334 } | 335 } |
335 } | 336 } |
336 | 337 |
337 } // namespace net | 338 } // namespace net |
OLD | NEW |