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/values.h" |
7 #include "chrome/common/child_process.h" | 8 #include "chrome/common/child_process.h" |
8 #include "chrome/common/extensions/extension_unpacker.h" | 9 #include "chrome/common/extensions/extension_unpacker.h" |
9 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
10 | 11 |
11 UtilityThread::UtilityThread() : ChildThread(base::Thread::Options()) { | 12 UtilityThread::UtilityThread() : ChildThread(base::Thread::Options()) { |
12 } | 13 } |
13 | 14 |
14 UtilityThread::~UtilityThread() { | 15 UtilityThread::~UtilityThread() { |
15 } | 16 } |
16 | 17 |
17 void UtilityThread::Init() { | 18 void UtilityThread::Init() { |
18 ChildThread::Init(); | 19 ChildThread::Init(); |
19 ChildProcess::current()->AddRefProcess(); | 20 ChildProcess::current()->AddRefProcess(); |
20 } | 21 } |
21 | 22 |
22 void UtilityThread::CleanUp() { | 23 void UtilityThread::CleanUp() { |
23 // Shutdown in reverse of the initialization order. | 24 // Shutdown in reverse of the initialization order. |
24 ChildThread::CleanUp(); | 25 ChildThread::CleanUp(); |
25 } | 26 } |
26 | 27 |
27 void UtilityThread::OnControlMessageReceived(const IPC::Message& msg) { | 28 void UtilityThread::OnControlMessageReceived(const IPC::Message& msg) { |
28 IPC_BEGIN_MESSAGE_MAP(UtilityThread, msg) | 29 IPC_BEGIN_MESSAGE_MAP(UtilityThread, msg) |
29 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackExtension, OnUnpackExtension) | 30 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackExtension, OnUnpackExtension) |
30 IPC_END_MESSAGE_MAP() | 31 IPC_END_MESSAGE_MAP() |
31 } | 32 } |
32 | 33 |
33 void UtilityThread::OnUnpackExtension(const FilePath& extension_path) { | 34 void UtilityThread::OnUnpackExtension(const FilePath& extension_path) { |
34 ExtensionUnpacker unpacker(extension_path); | 35 ExtensionUnpacker unpacker(extension_path); |
35 bool success = unpacker.Run(); | 36 if (unpacker.Run()) { |
36 Send(new UtilityHostMsg_UnpackExtension_Reply(success, | 37 Send(new UtilityHostMsg_UnpackExtension_Succeeded( |
37 unpacker.error_message())); | 38 *unpacker.parsed_manifest(), unpacker.decoded_images())); |
| 39 } else { |
| 40 Send(new UtilityHostMsg_UnpackExtension_Failed( |
| 41 unpacker.error_message())); |
| 42 } |
38 | 43 |
39 ChildProcess::current()->ReleaseProcess(); | 44 ChildProcess::current()->ReleaseProcess(); |
40 } | 45 } |
OLD | NEW |