| 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 13 matching lines...) Expand all Loading... |
| 24 BrowserThread::IO, | 24 BrowserThread::IO, |
| 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( | 34 UtilityProcessHost::Create(this, base::MessageLoopProxy::current().get()); |
| 35 this, base::MessageLoopProxy::current()); | |
| 36 host->EnableZygote(); | 35 host->EnableZygote(); |
| 37 host->Send(new ChromeUtilityMsg_ParseJSON(unsafe_json_)); | 36 host->Send(new ChromeUtilityMsg_ParseJSON(unsafe_json_)); |
| 38 } | 37 } |
| 39 | 38 |
| 40 void SafeJsonParser::OnJSONParseSucceeded(const base::ListValue& wrapper) { | 39 void SafeJsonParser::OnJSONParseSucceeded(const base::ListValue& wrapper) { |
| 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 42 const Value* value = NULL; | 41 const Value* value = NULL; |
| 43 CHECK(wrapper.Get(0, &value)); | 42 CHECK(wrapper.Get(0, &value)); |
| 44 | 43 |
| 45 parsed_json_.reset(value->DeepCopy()); | 44 parsed_json_.reset(value->DeepCopy()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 76 bool handled = true; | 75 bool handled = true; |
| 77 IPC_BEGIN_MESSAGE_MAP(SafeJsonParser, message) | 76 IPC_BEGIN_MESSAGE_MAP(SafeJsonParser, message) |
| 78 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Succeeded, | 77 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Succeeded, |
| 79 OnJSONParseSucceeded) | 78 OnJSONParseSucceeded) |
| 80 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Failed, | 79 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Failed, |
| 81 OnJSONParseFailed) | 80 OnJSONParseFailed) |
| 82 IPC_MESSAGE_UNHANDLED(handled = false) | 81 IPC_MESSAGE_UNHANDLED(handled = false) |
| 83 IPC_END_MESSAGE_MAP() | 82 IPC_END_MESSAGE_MAP() |
| 84 return handled; | 83 return handled; |
| 85 } | 84 } |
| OLD | NEW |