| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/utility/utility_thread.h" | 5 #include "chrome/utility/utility_thread.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/common/web_resource/web_resource_unpacker.h" | 9 #include "chrome/common/web_resource/web_resource_unpacker.h" |
| 10 #include "chrome/common/child_process.h" | 10 #include "chrome/common/child_process.h" |
| 11 #include "chrome/common/extensions/extension_unpacker.h" | 11 #include "chrome/common/extensions/extension_unpacker.h" |
| 12 #include "chrome/common/render_messages.h" | 12 #include "chrome/common/render_messages.h" |
| 13 | 13 |
| 14 UtilityThread::UtilityThread() : ChildThread(base::Thread::Options()) { | 14 UtilityThread::UtilityThread() { |
| 15 ChildProcess::current()->AddRefProcess(); |
| 15 } | 16 } |
| 16 | 17 |
| 17 UtilityThread::~UtilityThread() { | 18 UtilityThread::~UtilityThread() { |
| 18 } | 19 } |
| 19 | 20 |
| 20 void UtilityThread::Init() { | |
| 21 ChildThread::Init(); | |
| 22 ChildProcess::current()->AddRefProcess(); | |
| 23 } | |
| 24 | |
| 25 void UtilityThread::CleanUp() { | |
| 26 // Shutdown in reverse of the initialization order. | |
| 27 ChildThread::CleanUp(); | |
| 28 } | |
| 29 | |
| 30 void UtilityThread::OnControlMessageReceived(const IPC::Message& msg) { | 21 void UtilityThread::OnControlMessageReceived(const IPC::Message& msg) { |
| 31 IPC_BEGIN_MESSAGE_MAP(UtilityThread, msg) | 22 IPC_BEGIN_MESSAGE_MAP(UtilityThread, msg) |
| 32 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackExtension, OnUnpackExtension) | 23 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackExtension, OnUnpackExtension) |
| 33 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackWebResource, OnUnpackWebResource) | 24 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackWebResource, OnUnpackWebResource) |
| 34 IPC_END_MESSAGE_MAP() | 25 IPC_END_MESSAGE_MAP() |
| 35 } | 26 } |
| 36 | 27 |
| 37 void UtilityThread::OnUnpackExtension(const FilePath& extension_path) { | 28 void UtilityThread::OnUnpackExtension(const FilePath& extension_path) { |
| 38 ExtensionUnpacker unpacker(extension_path); | 29 ExtensionUnpacker unpacker(extension_path); |
| 39 if (unpacker.Run() && unpacker.DumpImagesToFile()) { | 30 if (unpacker.Run() && unpacker.DumpImagesToFile()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 55 Send(new UtilityHostMsg_UnpackWebResource_Succeeded( | 46 Send(new UtilityHostMsg_UnpackWebResource_Succeeded( |
| 56 *unpacker.parsed_json())); | 47 *unpacker.parsed_json())); |
| 57 } else { | 48 } else { |
| 58 Send(new UtilityHostMsg_UnpackWebResource_Failed( | 49 Send(new UtilityHostMsg_UnpackWebResource_Failed( |
| 59 unpacker.error_message())); | 50 unpacker.error_message())); |
| 60 } | 51 } |
| 61 | 52 |
| 62 ChildProcess::current()->ReleaseProcess(); | 53 ChildProcess::current()->ReleaseProcess(); |
| 63 } | 54 } |
| 64 | 55 |
| OLD | NEW |