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 "components/safe_json/safe_json_parser.h" | 10 #include "components/safe_json/safe_json_parser.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 if (!fetcher->GetStatus().is_success() || | 76 if (!fetcher->GetStatus().is_success() || |
77 fetcher->GetResponseCode() != 200) { | 77 fetcher->GetResponseCode() != 200) { |
78 delegate_->OnWebstoreRequestFailure(); | 78 delegate_->OnWebstoreRequestFailure(); |
79 return; | 79 return; |
80 } | 80 } |
81 | 81 |
82 std::string webstore_json_data; | 82 std::string webstore_json_data; |
83 fetcher->GetResponseAsString(&webstore_json_data); | 83 fetcher->GetResponseAsString(&webstore_json_data); |
84 | 84 |
85 scoped_refptr<safe_json::SafeJsonParser> parser = | |
86 new safe_json::SafeJsonParser( | |
87 webstore_json_data, | |
88 base::Bind(&WebstoreDataFetcher::OnJsonParseSuccess, AsWeakPtr()), | |
89 base::Bind(&WebstoreDataFetcher::OnJsonParseFailure, AsWeakPtr())); | |
90 // The parser will call us back via one of the callbacks. | 85 // The parser will call us back via one of the callbacks. |
91 parser->Start(); | 86 safe_json::SafeJsonParser::Parse( |
| 87 webstore_json_data, |
| 88 base::Bind(&WebstoreDataFetcher::OnJsonParseSuccess, AsWeakPtr()), |
| 89 base::Bind(&WebstoreDataFetcher::OnJsonParseFailure, AsWeakPtr())); |
92 } | 90 } |
93 | 91 |
94 } // namespace extensions | 92 } // namespace extensions |
OLD | NEW |