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/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/webstore_data_fetcher_delegate.h" | 8 #include "chrome/browser/extensions/webstore_data_fetcher_delegate.h" |
9 #include "chrome/common/chrome_utility_messages.h" | 9 #include "chrome/common/chrome_utility_messages.h" |
10 #include "chrome/common/extensions/extension_constants.h" | 10 #include "chrome/common/extensions/extension_constants.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 BrowserThread::UI, | 92 BrowserThread::UI, |
93 FROM_HERE, | 93 FROM_HERE, |
94 base::Bind(&SafeWebstoreResponseParser::ReportResultOnUIThread, this)); | 94 base::Bind(&SafeWebstoreResponseParser::ReportResultOnUIThread, this)); |
95 } | 95 } |
96 | 96 |
97 void ReportResultOnUIThread() { | 97 void ReportResultOnUIThread() { |
98 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 98 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
99 if (!client_) | 99 if (!client_) |
100 return; | 100 return; |
101 | 101 |
102 if (error_.empty() && parsed_webstore_data_.get()) { | 102 if (error_.empty() && parsed_webstore_data_) { |
103 client_->OnWebstoreResponseParseSuccess(parsed_webstore_data_.release()); | 103 client_->OnWebstoreResponseParseSuccess(parsed_webstore_data_.release()); |
104 } else { | 104 } else { |
105 client_->OnWebstoreResponseParseFailure(error_); | 105 client_->OnWebstoreResponseParseFailure(error_); |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 private: | 109 private: |
110 virtual ~SafeWebstoreResponseParser() {} | 110 virtual ~SafeWebstoreResponseParser() {} |
111 | 111 |
112 base::WeakPtr<WebstoreDataFetcher> client_; | 112 base::WeakPtr<WebstoreDataFetcher> client_; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 fetcher->GetResponseAsString(&webstore_json_data); | 168 fetcher->GetResponseAsString(&webstore_json_data); |
169 | 169 |
170 scoped_refptr<SafeWebstoreResponseParser> parser = | 170 scoped_refptr<SafeWebstoreResponseParser> parser = |
171 new SafeWebstoreResponseParser(AsWeakPtr(), webstore_json_data); | 171 new SafeWebstoreResponseParser(AsWeakPtr(), webstore_json_data); |
172 // The parser will call us back via OnWebstoreResponseParseSucces or | 172 // The parser will call us back via OnWebstoreResponseParseSucces or |
173 // OnWebstoreResponseParseFailure. | 173 // OnWebstoreResponseParseFailure. |
174 parser->Start(); | 174 parser->Start(); |
175 } | 175 } |
176 | 176 |
177 } // namespace extensions | 177 } // namespace extensions |
OLD | NEW |