| 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 "chrome/browser/safe_json_parser.h" | 5 #include "chrome/browser/safe_json_parser.h" |
| 6 | 6 |
| 7 #include "chrome/common/chrome_utility_messages.h" | 7 #include "chrome/common/chrome_utility_messages.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/browser/utility_process_host.h" | 9 #include "content/public/browser/utility_process_host.h" |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 FROM_HERE, | 25 FROM_HERE, |
| 26 base::Bind(&SafeJsonParser::StartWorkOnIOThread, this)); | 26 base::Bind(&SafeJsonParser::StartWorkOnIOThread, this)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 SafeJsonParser::~SafeJsonParser() {} | 29 SafeJsonParser::~SafeJsonParser() {} |
| 30 | 30 |
| 31 void SafeJsonParser::StartWorkOnIOThread() { | 31 void SafeJsonParser::StartWorkOnIOThread() { |
| 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 33 UtilityProcessHost* host = | 33 UtilityProcessHost* host = |
| 34 UtilityProcessHost::Create(this, base::MessageLoopProxy::current().get()); | 34 UtilityProcessHost::Create(this, base::MessageLoopProxy::current().get()); |
| 35 host->EnableZygote(); | |
| 36 host->Send(new ChromeUtilityMsg_ParseJSON(unsafe_json_)); | 35 host->Send(new ChromeUtilityMsg_ParseJSON(unsafe_json_)); |
| 37 } | 36 } |
| 38 | 37 |
| 39 void SafeJsonParser::OnJSONParseSucceeded(const base::ListValue& wrapper) { | 38 void SafeJsonParser::OnJSONParseSucceeded(const base::ListValue& wrapper) { |
| 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 41 const Value* value = NULL; | 40 const Value* value = NULL; |
| 42 CHECK(wrapper.Get(0, &value)); | 41 CHECK(wrapper.Get(0, &value)); |
| 43 | 42 |
| 44 parsed_json_.reset(value->DeepCopy()); | 43 parsed_json_.reset(value->DeepCopy()); |
| 45 ReportResults(); | 44 ReportResults(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 75 bool handled = true; | 74 bool handled = true; |
| 76 IPC_BEGIN_MESSAGE_MAP(SafeJsonParser, message) | 75 IPC_BEGIN_MESSAGE_MAP(SafeJsonParser, message) |
| 77 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Succeeded, | 76 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Succeeded, |
| 78 OnJSONParseSucceeded) | 77 OnJSONParseSucceeded) |
| 79 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Failed, | 78 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Failed, |
| 80 OnJSONParseFailed) | 79 OnJSONParseFailed) |
| 81 IPC_MESSAGE_UNHANDLED(handled = false) | 80 IPC_MESSAGE_UNHANDLED(handled = false) |
| 82 IPC_END_MESSAGE_MAP() | 81 IPC_END_MESSAGE_MAP() |
| 83 return handled; | 82 return handled; |
| 84 } | 83 } |
| OLD | NEW |