OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/extensions/webstore_data_fetcher.h" | 5 #include "chrome/browser/extensions/webstore_data_fetcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/webstore_data_fetcher_delegate.h" | 9 #include "chrome/browser/extensions/webstore_data_fetcher_delegate.h" |
10 #include "chrome/browser/safe_json_parser.h" | 10 #include "chrome/browser/safe_json_parser.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 WebstoreDataFetcher::WebstoreDataFetcher( | 24 WebstoreDataFetcher::WebstoreDataFetcher( |
25 WebstoreDataFetcherDelegate* delegate, | 25 WebstoreDataFetcherDelegate* delegate, |
26 net::URLRequestContextGetter* request_context, | 26 net::URLRequestContextGetter* request_context, |
27 const GURL& referrer_url, | 27 const GURL& referrer_url, |
28 const std::string webstore_item_id) | 28 const std::string webstore_item_id) |
29 : delegate_(delegate), | 29 : delegate_(delegate), |
30 request_context_(request_context), | 30 request_context_(request_context), |
31 referrer_url_(referrer_url), | 31 referrer_url_(referrer_url), |
32 id_(webstore_item_id) { | 32 id_(webstore_item_id), |
33 max_auto_retries_(0) { | |
33 } | 34 } |
34 | 35 |
35 WebstoreDataFetcher::~WebstoreDataFetcher() {} | 36 WebstoreDataFetcher::~WebstoreDataFetcher() {} |
36 | 37 |
37 void WebstoreDataFetcher::Start() { | 38 void WebstoreDataFetcher::Start() { |
38 GURL webstore_data_url(extension_urls::GetWebstoreItemJsonDataURL(id_)); | 39 GURL webstore_data_url(extension_urls::GetWebstoreItemJsonDataURL(id_)); |
39 | 40 |
40 webstore_data_url_fetcher_.reset(net::URLFetcher::Create( | 41 webstore_data_url_fetcher_.reset(net::URLFetcher::Create( |
41 webstore_data_url, net::URLFetcher::GET, this)); | 42 webstore_data_url, net::URLFetcher::GET, this)); |
42 webstore_data_url_fetcher_->SetRequestContext(request_context_); | 43 webstore_data_url_fetcher_->SetRequestContext(request_context_); |
43 webstore_data_url_fetcher_->SetReferrer(referrer_url_.spec()); | 44 webstore_data_url_fetcher_->SetReferrer(referrer_url_.spec()); |
44 webstore_data_url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 45 webstore_data_url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | |
45 net::LOAD_DISABLE_CACHE); | 46 net::LOAD_DISABLE_CACHE); |
47 webstore_data_url_fetcher_->SetMaxRetriesOn5xx(max_auto_retries_); | |
asargent_no_longer_on_chrome
2014/07/10 23:08:34
Should you only call this if max_auto_retries_ is
xiyuan
2014/07/10 23:23:13
The code assumes that the default retry numbers in
asargent_no_longer_on_chrome
2014/07/10 23:49:06
Yeah, I'm not sure. The URLFetcher header comments
xiyuan
2014/07/11 04:05:44
Okay. Think it makes more sense than assuming the
| |
48 webstore_data_url_fetcher_->SetAutomaticallyRetryOnNetworkChanges( | |
49 max_auto_retries_); | |
46 webstore_data_url_fetcher_->Start(); | 50 webstore_data_url_fetcher_->Start(); |
47 } | 51 } |
48 | 52 |
49 void WebstoreDataFetcher::OnJsonParseSuccess( | 53 void WebstoreDataFetcher::OnJsonParseSuccess( |
50 scoped_ptr<base::Value> parsed_json) { | 54 scoped_ptr<base::Value> parsed_json) { |
51 if (!parsed_json->IsType(base::Value::TYPE_DICTIONARY)) { | 55 if (!parsed_json->IsType(base::Value::TYPE_DICTIONARY)) { |
52 OnJsonParseFailure(kInvalidWebstoreResponseError); | 56 OnJsonParseFailure(kInvalidWebstoreResponseError); |
53 return; | 57 return; |
54 } | 58 } |
55 | 59 |
(...skipping 24 matching lines...) Expand all Loading... | |
80 new SafeJsonParser(webstore_json_data, | 84 new SafeJsonParser(webstore_json_data, |
81 base::Bind(&WebstoreDataFetcher::OnJsonParseSuccess, | 85 base::Bind(&WebstoreDataFetcher::OnJsonParseSuccess, |
82 AsWeakPtr()), | 86 AsWeakPtr()), |
83 base::Bind(&WebstoreDataFetcher::OnJsonParseFailure, | 87 base::Bind(&WebstoreDataFetcher::OnJsonParseFailure, |
84 AsWeakPtr())); | 88 AsWeakPtr())); |
85 // The parser will call us back via one of the callbacks. | 89 // The parser will call us back via one of the callbacks. |
86 parser->Start(); | 90 parser->Start(); |
87 } | 91 } |
88 | 92 |
89 } // namespace extensions | 93 } // namespace extensions |
OLD | NEW |