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 "ios/chrome/browser/web_resource/web_resource_util.h" | 5 #include "ios/chrome/browser/web_resource/web_resource_util.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/task_runner.h" | 10 #include "base/task_runner.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 void ParseJSONOnBackgroundThread( | 35 void ParseJSONOnBackgroundThread( |
36 base::TaskRunner* task_runner, | 36 base::TaskRunner* task_runner, |
37 const std::string& data, | 37 const std::string& data, |
38 const WebResourceService::SuccessCallback& success_callback, | 38 const WebResourceService::SuccessCallback& success_callback, |
39 const WebResourceService::ErrorCallback& error_callback) { | 39 const WebResourceService::ErrorCallback& error_callback) { |
40 if (data.empty()) { | 40 if (data.empty()) { |
41 PostErrorTask(task_runner, error_callback, kInvalidDataTypeError); | 41 PostErrorTask(task_runner, error_callback, kInvalidDataTypeError); |
42 return; | 42 return; |
43 } | 43 } |
44 | 44 |
45 scoped_ptr<base::Value> value(base::JSONReader::Read(data)); | 45 std::unique_ptr<base::Value> value(base::JSONReader::Read(data)); |
46 if (!value.get()) { | 46 if (!value.get()) { |
47 // Page information not properly read, or corrupted. | 47 // Page information not properly read, or corrupted. |
48 PostErrorTask(task_runner, error_callback, kInvalidDataTypeError); | 48 PostErrorTask(task_runner, error_callback, kInvalidDataTypeError); |
49 return; | 49 return; |
50 } | 50 } |
51 | 51 |
52 if (!value->IsType(base::Value::TYPE_DICTIONARY)) { | 52 if (!value->IsType(base::Value::TYPE_DICTIONARY)) { |
53 PostErrorTask(task_runner, error_callback, kUnexpectedJSONFormatError); | 53 PostErrorTask(task_runner, error_callback, kUnexpectedJSONFormatError); |
54 return; | 54 return; |
55 } | 55 } |
(...skipping 15 matching lines...) Expand all Loading... |
71 success_callback, error_callback)); | 71 success_callback, error_callback)); |
72 } | 72 } |
73 | 73 |
74 } // namespace | 74 } // namespace |
75 | 75 |
76 WebResourceService::ParseJSONCallback GetIOSChromeParseJSONCallback() { | 76 WebResourceService::ParseJSONCallback GetIOSChromeParseJSONCallback() { |
77 return base::Bind(&StartParseJSONAsync); | 77 return base::Bind(&StartParseJSONAsync); |
78 } | 78 } |
79 | 79 |
80 } // namespace web_resource | 80 } // namespace web_resource |
OLD | NEW |