| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 base::Bind(&SafeJsonParserImpl::OnParseDone, base::Unretained(this))); | 49 base::Bind(&SafeJsonParserImpl::OnParseDone, base::Unretained(this))); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void SafeJsonParserImpl::OnConnectionError() { | 52 void SafeJsonParserImpl::OnConnectionError() { |
| 53 DCHECK(io_thread_checker_.CalledOnValidThread()); | 53 DCHECK(io_thread_checker_.CalledOnValidThread()); |
| 54 | 54 |
| 55 // Shut down the utility process. | 55 // Shut down the utility process. |
| 56 mojo_json_parser_.reset(); | 56 mojo_json_parser_.reset(); |
| 57 | 57 |
| 58 caller_task_runner_->PostTask( | 58 caller_task_runner_->PostTask( |
| 59 FROM_HERE, base::Bind(&SafeJsonParserImpl::ReportResults, | 59 FROM_HERE, |
| 60 base::Unretained(this), nullptr, "Json error")); | 60 base::Bind(&SafeJsonParserImpl::ReportResults, base::Unretained(this), |
| 61 nullptr, "Connection error with the json parser process.")); |
| 61 } | 62 } |
| 62 | 63 |
| 63 void SafeJsonParserImpl::OnParseDone(const base::ListValue& wrapper, | 64 void SafeJsonParserImpl::OnParseDone(const base::ListValue& wrapper, |
| 64 const base::Optional<std::string>& error) { | 65 const base::Optional<std::string>& error) { |
| 65 DCHECK(io_thread_checker_.CalledOnValidThread()); | 66 DCHECK(io_thread_checker_.CalledOnValidThread()); |
| 66 | 67 |
| 67 // Shut down the utility process. | 68 // Shut down the utility process. |
| 68 mojo_json_parser_.reset(); | 69 mojo_json_parser_.reset(); |
| 69 | 70 |
| 70 std::unique_ptr<base::Value> parsed_json; | 71 std::unique_ptr<base::Value> parsed_json; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 94 if (!error_callback_.is_null()) | 95 if (!error_callback_.is_null()) |
| 95 error_callback_.Run(error); | 96 error_callback_.Run(error); |
| 96 } | 97 } |
| 97 | 98 |
| 98 // The parsing is done whether an error occured or not, so this instance can | 99 // The parsing is done whether an error occured or not, so this instance can |
| 99 // be cleaned up. | 100 // be cleaned up. |
| 100 delete this; | 101 delete this; |
| 101 } | 102 } |
| 102 | 103 |
| 103 } // namespace safe_json | 104 } // namespace safe_json |
| OLD | NEW |