| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 | 45 |
| 46 UtilityThread::UtilityThread() | 46 UtilityThread::UtilityThread() |
| 47 : batch_mode_(false) { | 47 : batch_mode_(false) { |
| 48 ChildProcess::current()->AddRefProcess(); | 48 ChildProcess::current()->AddRefProcess(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 UtilityThread::~UtilityThread() { | 51 UtilityThread::~UtilityThread() { |
| 52 } | 52 } |
| 53 | 53 |
| 54 void UtilityThread::OnControlMessageReceived(const IPC::Message& msg) { | 54 bool UtilityThread::OnControlMessageReceived(const IPC::Message& msg) { |
| 55 bool handled = true; |
| 55 IPC_BEGIN_MESSAGE_MAP(UtilityThread, msg) | 56 IPC_BEGIN_MESSAGE_MAP(UtilityThread, msg) |
| 56 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackExtension, OnUnpackExtension) | 57 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackExtension, OnUnpackExtension) |
| 57 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackWebResource, OnUnpackWebResource) | 58 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackWebResource, OnUnpackWebResource) |
| 58 IPC_MESSAGE_HANDLER(UtilityMsg_ParseUpdateManifest, OnParseUpdateManifest) | 59 IPC_MESSAGE_HANDLER(UtilityMsg_ParseUpdateManifest, OnParseUpdateManifest) |
| 59 IPC_MESSAGE_HANDLER(UtilityMsg_DecodeImage, OnDecodeImage) | 60 IPC_MESSAGE_HANDLER(UtilityMsg_DecodeImage, OnDecodeImage) |
| 60 IPC_MESSAGE_HANDLER(UtilityMsg_RenderPDFPagesToMetafile, | 61 IPC_MESSAGE_HANDLER(UtilityMsg_RenderPDFPagesToMetafile, |
| 61 OnRenderPDFPagesToMetafile) | 62 OnRenderPDFPagesToMetafile) |
| 62 IPC_MESSAGE_HANDLER(UtilityMsg_IDBKeysFromValuesAndKeyPath, | 63 IPC_MESSAGE_HANDLER(UtilityMsg_IDBKeysFromValuesAndKeyPath, |
| 63 OnIDBKeysFromValuesAndKeyPath) | 64 OnIDBKeysFromValuesAndKeyPath) |
| 64 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) | 65 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) |
| 65 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) | 66 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) |
| 66 IPC_MESSAGE_HANDLER(UtilityMsg_GetPrinterCapsAndDefaults, | 67 IPC_MESSAGE_HANDLER(UtilityMsg_GetPrinterCapsAndDefaults, |
| 67 OnGetPrinterCapsAndDefaults) | 68 OnGetPrinterCapsAndDefaults) |
| 69 IPC_MESSAGE_UNHANDLED(handled = false) |
| 68 IPC_END_MESSAGE_MAP() | 70 IPC_END_MESSAGE_MAP() |
| 71 return handled; |
| 69 } | 72 } |
| 70 | 73 |
| 71 void UtilityThread::OnUnpackExtension(const FilePath& extension_path) { | 74 void UtilityThread::OnUnpackExtension(const FilePath& extension_path) { |
| 72 ExtensionUnpacker unpacker(extension_path); | 75 ExtensionUnpacker unpacker(extension_path); |
| 73 if (unpacker.Run() && unpacker.DumpImagesToFile() && | 76 if (unpacker.Run() && unpacker.DumpImagesToFile() && |
| 74 unpacker.DumpMessageCatalogsToFile()) { | 77 unpacker.DumpMessageCatalogsToFile()) { |
| 75 Send(new UtilityHostMsg_UnpackExtension_Succeeded( | 78 Send(new UtilityHostMsg_UnpackExtension_Succeeded( |
| 76 *unpacker.parsed_manifest())); | 79 *unpacker.parsed_manifest())); |
| 77 } else { | 80 } else { |
| 78 Send(new UtilityHostMsg_UnpackExtension_Failed(unpacker.error_message())); | 81 Send(new UtilityHostMsg_UnpackExtension_Failed(unpacker.error_message())); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name)); | 323 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name)); |
| 321 } | 324 } |
| 322 ReleaseProcessIfNeeded(); | 325 ReleaseProcessIfNeeded(); |
| 323 } | 326 } |
| 324 | 327 |
| 325 void UtilityThread::ReleaseProcessIfNeeded() { | 328 void UtilityThread::ReleaseProcessIfNeeded() { |
| 326 if (!batch_mode_) | 329 if (!batch_mode_) |
| 327 ChildProcess::current()->ReleaseProcess(); | 330 ChildProcess::current()->ReleaseProcess(); |
| 328 } | 331 } |
| 329 | 332 |
| OLD | NEW |