| 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() { | 14 UtilityThread::UtilityThread() : ChildThread(base::Thread::Options()) { |
| 15 ChildProcess::current()->AddRefProcess(); | |
| 16 } | 15 } |
| 17 | 16 |
| 18 UtilityThread::~UtilityThread() { | 17 UtilityThread::~UtilityThread() { |
| 19 } | 18 } |
| 20 | 19 |
| 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 |
| 21 void UtilityThread::OnControlMessageReceived(const IPC::Message& msg) { | 30 void UtilityThread::OnControlMessageReceived(const IPC::Message& msg) { |
| 22 IPC_BEGIN_MESSAGE_MAP(UtilityThread, msg) | 31 IPC_BEGIN_MESSAGE_MAP(UtilityThread, msg) |
| 23 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackExtension, OnUnpackExtension) | 32 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackExtension, OnUnpackExtension) |
| 24 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackWebResource, OnUnpackWebResource) | 33 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackWebResource, OnUnpackWebResource) |
| 25 IPC_END_MESSAGE_MAP() | 34 IPC_END_MESSAGE_MAP() |
| 26 } | 35 } |
| 27 | 36 |
| 28 void UtilityThread::OnUnpackExtension(const FilePath& extension_path) { | 37 void UtilityThread::OnUnpackExtension(const FilePath& extension_path) { |
| 29 ExtensionUnpacker unpacker(extension_path); | 38 ExtensionUnpacker unpacker(extension_path); |
| 30 if (unpacker.Run() && unpacker.DumpImagesToFile()) { | 39 if (unpacker.Run() && unpacker.DumpImagesToFile()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 46 Send(new UtilityHostMsg_UnpackWebResource_Succeeded( | 55 Send(new UtilityHostMsg_UnpackWebResource_Succeeded( |
| 47 *unpacker.parsed_json())); | 56 *unpacker.parsed_json())); |
| 48 } else { | 57 } else { |
| 49 Send(new UtilityHostMsg_UnpackWebResource_Failed( | 58 Send(new UtilityHostMsg_UnpackWebResource_Failed( |
| 50 unpacker.error_message())); | 59 unpacker.error_message())); |
| 51 } | 60 } |
| 52 | 61 |
| 53 ChildProcess::current()->ReleaseProcess(); | 62 ChildProcess::current()->ReleaseProcess(); |
| 54 } | 63 } |
| 55 | 64 |
| OLD | NEW |