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 "components/safe_json/safe_json_parser_impl.h" | 5 #include "components/safe_json/safe_json_parser_impl.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/sequenced_task_runner.h" | 8 #include "base/sequenced_task_runner.h" |
9 #include "base/threading/sequenced_task_runner_handle.h" | 9 #include "base/threading/sequenced_task_runner_handle.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 // Call ReportResults() on caller's thread. | 71 // Call ReportResults() on caller's thread. |
72 caller_task_runner_->PostTask( | 72 caller_task_runner_->PostTask( |
73 FROM_HERE, | 73 FROM_HERE, |
74 base::Bind(&SafeJsonParserImpl::ReportResults, base::Unretained(this), | 74 base::Bind(&SafeJsonParserImpl::ReportResults, base::Unretained(this), |
75 base::Passed(&result), error.value_or(""))); | 75 base::Passed(&result), error.value_or(""))); |
76 } | 76 } |
77 | 77 |
78 void SafeJsonParserImpl::ReportResults(std::unique_ptr<base::Value> parsed_json, | 78 void SafeJsonParserImpl::ReportResults(std::unique_ptr<base::Value> parsed_json, |
79 const std::string& error) { | 79 const std::string& error) { |
80 DCHECK(caller_task_runner_->RunsTasksOnCurrentThread()); | 80 DCHECK(caller_task_runner_->RunsTasksInCurrentSequence()); |
81 if (error.empty() && parsed_json) { | 81 if (error.empty() && parsed_json) { |
82 if (!success_callback_.is_null()) | 82 if (!success_callback_.is_null()) |
83 success_callback_.Run(std::move(parsed_json)); | 83 success_callback_.Run(std::move(parsed_json)); |
84 } else { | 84 } else { |
85 if (!error_callback_.is_null()) | 85 if (!error_callback_.is_null()) |
86 error_callback_.Run(error); | 86 error_callback_.Run(error); |
87 } | 87 } |
88 | 88 |
89 // The parsing is done whether an error occured or not, so this instance can | 89 // The parsing is done whether an error occured or not, so this instance can |
90 // be cleaned up. | 90 // be cleaned up. |
91 delete this; | 91 delete this; |
92 } | 92 } |
93 | 93 |
94 } // namespace safe_json | 94 } // namespace safe_json |
OLD | NEW |