Chromium Code Reviews| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 webstore_data_url_fetcher_->Start(); | 46 webstore_data_url_fetcher_->Start(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void WebstoreDataFetcher::OnJsonParseSuccess( | 49 void WebstoreDataFetcher::OnJsonParseSuccess( |
| 50 scoped_ptr<base::Value> parsed_json) { | 50 scoped_ptr<base::Value> parsed_json) { |
| 51 if (!parsed_json->IsType(base::Value::TYPE_DICTIONARY)) { | 51 if (!parsed_json->IsType(base::Value::TYPE_DICTIONARY)) { |
| 52 OnJsonParseFailure(kInvalidWebstoreResponseError); | 52 OnJsonParseFailure(kInvalidWebstoreResponseError); |
| 53 return; | 53 return; |
| 54 } | 54 } |
| 55 | 55 |
| 56 delegate_->OnWebstoreResponseParseSuccess( | 56 delegate_->OnWebstoreResponseParseSuccess(scoped_ptr<base::DictionaryValue>( |
| 57 static_cast<base::DictionaryValue*>(parsed_json.release())); | 57 static_cast<base::DictionaryValue*>(parsed_json.release()))); |
|
benwells
2013/11/01 06:01:01
fun times :)
| |
| 58 } | 58 } |
| 59 | 59 |
| 60 void WebstoreDataFetcher::OnJsonParseFailure( | 60 void WebstoreDataFetcher::OnJsonParseFailure( |
| 61 const std::string& error) { | 61 const std::string& error) { |
| 62 delegate_->OnWebstoreResponseParseFailure(error); | 62 delegate_->OnWebstoreResponseParseFailure(error); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void WebstoreDataFetcher::OnURLFetchComplete(const net::URLFetcher* source) { | 65 void WebstoreDataFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
| 66 CHECK_EQ(webstore_data_url_fetcher_.get(), source); | 66 CHECK_EQ(webstore_data_url_fetcher_.get(), source); |
| 67 | 67 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 80 new SafeJsonParser(webstore_json_data, | 80 new SafeJsonParser(webstore_json_data, |
| 81 base::Bind(&WebstoreDataFetcher::OnJsonParseSuccess, | 81 base::Bind(&WebstoreDataFetcher::OnJsonParseSuccess, |
| 82 AsWeakPtr()), | 82 AsWeakPtr()), |
| 83 base::Bind(&WebstoreDataFetcher::OnJsonParseFailure, | 83 base::Bind(&WebstoreDataFetcher::OnJsonParseFailure, |
| 84 AsWeakPtr())); | 84 AsWeakPtr())); |
| 85 // The parser will call us back via one of the callbacks. | 85 // The parser will call us back via one of the callbacks. |
| 86 parser->Start(); | 86 parser->Start(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 } // namespace extensions | 89 } // namespace extensions |
| OLD | NEW |