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_parser/safe_json_parser.h" | 5 #include "components/safe_json_parser/safe_json_parser.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/thread_task_runner_handle.h" |
10 #include "base/tuple.h" | 11 #include "base/tuple.h" |
11 #include "base/values.h" | 12 #include "base/values.h" |
12 #include "components/safe_json_parser/safe_json_parser_messages.h" | 13 #include "components/safe_json_parser/safe_json_parser_messages.h" |
13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/utility_process_host.h" | 15 #include "content/public/browser/utility_process_host.h" |
15 #include "grit/components_strings.h" | 16 #include "grit/components_strings.h" |
16 #include "ipc/ipc_message_macros.h" | 17 #include "ipc/ipc_message_macros.h" |
17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
18 | 19 |
19 using content::BrowserThread; | 20 using content::BrowserThread; |
(...skipping 14 matching lines...) Expand all Loading... |
34 BrowserThread::PostTask( | 35 BrowserThread::PostTask( |
35 BrowserThread::IO, FROM_HERE, | 36 BrowserThread::IO, FROM_HERE, |
36 base::Bind(&SafeJsonParser::StartWorkOnIOThread, this)); | 37 base::Bind(&SafeJsonParser::StartWorkOnIOThread, this)); |
37 } | 38 } |
38 | 39 |
39 SafeJsonParser::~SafeJsonParser() { | 40 SafeJsonParser::~SafeJsonParser() { |
40 } | 41 } |
41 | 42 |
42 void SafeJsonParser::StartWorkOnIOThread() { | 43 void SafeJsonParser::StartWorkOnIOThread() { |
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
44 UtilityProcessHost* host = | 45 UtilityProcessHost* host = UtilityProcessHost::Create( |
45 UtilityProcessHost::Create(this, base::MessageLoopProxy::current().get()); | 46 this, base::ThreadTaskRunnerHandle::Get().get()); |
46 host->SetName( | 47 host->SetName( |
47 l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_JSON_PARSER_NAME)); | 48 l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_JSON_PARSER_NAME)); |
48 host->Send(new SafeJsonParserMsg_ParseJSON(unsafe_json_)); | 49 host->Send(new SafeJsonParserMsg_ParseJSON(unsafe_json_)); |
49 } | 50 } |
50 | 51 |
51 void SafeJsonParser::OnJSONParseSucceeded(const base::ListValue& wrapper) { | 52 void SafeJsonParser::OnJSONParseSucceeded(const base::ListValue& wrapper) { |
52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
53 const base::Value* value = NULL; | 54 const base::Value* value = NULL; |
54 CHECK(wrapper.Get(0, &value)); | 55 CHECK(wrapper.Get(0, &value)); |
55 | 56 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 IPC_MESSAGE_HANDLER(SafeJsonParserHostMsg_ParseJSON_Succeeded, | 89 IPC_MESSAGE_HANDLER(SafeJsonParserHostMsg_ParseJSON_Succeeded, |
89 OnJSONParseSucceeded) | 90 OnJSONParseSucceeded) |
90 IPC_MESSAGE_HANDLER(SafeJsonParserHostMsg_ParseJSON_Failed, | 91 IPC_MESSAGE_HANDLER(SafeJsonParserHostMsg_ParseJSON_Failed, |
91 OnJSONParseFailed) | 92 OnJSONParseFailed) |
92 IPC_MESSAGE_UNHANDLED(handled = false) | 93 IPC_MESSAGE_UNHANDLED(handled = false) |
93 IPC_END_MESSAGE_MAP() | 94 IPC_END_MESSAGE_MAP() |
94 return handled; | 95 return handled; |
95 } | 96 } |
96 | 97 |
97 } // namespace safe_json_parser | 98 } // namespace safe_json_parser |
OLD | NEW |