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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, base::Bind(&SafeJsonParserImpl::ReportResults, |
60 base::Unretained(this), nullptr, "Json error")); | 60 base::Unretained(this), nullptr, "Json error")); |
61 } | 61 } |
62 | 62 |
63 void SafeJsonParserImpl::OnParseDone(const base::ListValue& wrapper, | 63 void SafeJsonParserImpl::OnParseDone(const base::ListValue& wrapper, |
64 const mojo::String& error) { | 64 mojo::String error) { |
65 DCHECK(io_thread_checker_.CalledOnValidThread()); | 65 DCHECK(io_thread_checker_.CalledOnValidThread()); |
66 | 66 |
67 // Shut down the utility process. | 67 // Shut down the utility process. |
68 mojo_json_parser_.reset(); | 68 mojo_json_parser_.reset(); |
69 | 69 |
70 std::unique_ptr<base::Value> parsed_json; | 70 std::unique_ptr<base::Value> parsed_json; |
71 std::string error_message; | 71 std::string error_message; |
72 if (!wrapper.empty()) { | 72 if (!wrapper.empty()) { |
73 const base::Value* value = nullptr; | 73 const base::Value* value = nullptr; |
74 CHECK(wrapper.Get(0, &value)); | 74 CHECK(wrapper.Get(0, &value)); |
(...skipping 19 matching lines...) Expand all Loading... |
94 if (!error_callback_.is_null()) | 94 if (!error_callback_.is_null()) |
95 error_callback_.Run(error); | 95 error_callback_.Run(error); |
96 } | 96 } |
97 | 97 |
98 // The parsing is done whether an error occured or not, so this instance can | 98 // The parsing is done whether an error occured or not, so this instance can |
99 // be cleaned up. | 99 // be cleaned up. |
100 delete this; | 100 delete this; |
101 } | 101 } |
102 | 102 |
103 } // namespace safe_json | 103 } // namespace safe_json |
OLD | NEW |