OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "shell/application_manager/network_fetcher.h" | 5 #include "shell/application_manager/network_fetcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 url_(url), | 32 url_(url), |
33 weak_ptr_factory_(this) { | 33 weak_ptr_factory_(this) { |
34 StartNetworkRequest(url, network_service); | 34 StartNetworkRequest(url, network_service); |
35 } | 35 } |
36 | 36 |
37 NetworkFetcher::~NetworkFetcher() { | 37 NetworkFetcher::~NetworkFetcher() { |
38 if (!path_.empty()) | 38 if (!path_.empty()) |
39 base::DeleteFile(path_, false); | 39 base::DeleteFile(path_, false); |
40 } | 40 } |
41 | 41 |
42 const GURL& NetworkFetcher::GetURL() const { | |
43 return url_; | |
44 } | |
45 | |
46 GURL NetworkFetcher::GetRedirectURL() const { | |
47 if (!response_) | |
48 return GURL::EmptyGURL(); | |
49 | |
50 if (response_->redirect_url.is_null()) | |
51 return GURL::EmptyGURL(); | |
52 | |
53 return GURL(response_->redirect_url); | |
qsr
2015/02/25 14:50:27
Did you test this?
The doc for those fields are:
Aaron Boodman
2015/02/25 18:43:08
Ah, you are right. Fixed.
| |
54 } | |
55 | |
42 URLResponsePtr NetworkFetcher::AsURLResponse(base::TaskRunner* task_runner, | 56 URLResponsePtr NetworkFetcher::AsURLResponse(base::TaskRunner* task_runner, |
43 uint32_t skip) { | 57 uint32_t skip) { |
44 if (skip != 0) { | 58 if (skip != 0) { |
45 MojoResult result = ReadDataRaw( | 59 MojoResult result = ReadDataRaw( |
46 response_->body.get(), nullptr, &skip, | 60 response_->body.get(), nullptr, &skip, |
47 MOJO_READ_DATA_FLAG_ALL_OR_NONE | MOJO_READ_DATA_FLAG_DISCARD); | 61 MOJO_READ_DATA_FLAG_ALL_OR_NONE | MOJO_READ_DATA_FLAG_DISCARD); |
48 DCHECK_EQ(result, MOJO_RESULT_OK); | 62 DCHECK_EQ(result, MOJO_RESULT_OK); |
49 } | 63 } |
50 return response_.Pass(); | 64 return response_.Pass(); |
51 } | 65 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 << "while fetching " << response->url; | 207 << "while fetching " << response->url; |
194 loader_callback_.Run(make_scoped_ptr<Fetcher>(NULL)); | 208 loader_callback_.Run(make_scoped_ptr<Fetcher>(NULL)); |
195 return; | 209 return; |
196 } | 210 } |
197 | 211 |
198 response_ = response.Pass(); | 212 response_ = response.Pass(); |
199 loader_callback_.Run(make_scoped_ptr(this)); | 213 loader_callback_.Run(make_scoped_ptr(this)); |
200 } | 214 } |
201 | 215 |
202 } // namespace mojo | 216 } // namespace mojo |
OLD | NEW |