| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_UTILITY_UTILITY_THREAD_H_ | |
| 6 #define CHROME_UTILITY_UTILITY_THREAD_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/string16.h" | |
| 14 #include "base/platform_file.h" | |
| 15 #include "content/common/child_thread.h" | |
| 16 | |
| 17 class FilePath; | |
| 18 class IndexedDBKey; | |
| 19 class SerializedScriptValue; | |
| 20 | |
| 21 namespace gfx { | |
| 22 class Rect; | |
| 23 } | |
| 24 | |
| 25 namespace IPC { | |
| 26 class Message; | |
| 27 } | |
| 28 | |
| 29 namespace printing { | |
| 30 struct PageRange; | |
| 31 } | |
| 32 | |
| 33 // This class represents the background thread where the utility task runs. | |
| 34 class UtilityThread : public ChildThread { | |
| 35 public: | |
| 36 UtilityThread(); | |
| 37 virtual ~UtilityThread(); | |
| 38 | |
| 39 // Returns the one utility thread. | |
| 40 static UtilityThread* current() { | |
| 41 return static_cast<UtilityThread*>(ChildThread::current()); | |
| 42 } | |
| 43 | |
| 44 private: | |
| 45 // IPC messages | |
| 46 virtual bool OnControlMessageReceived(const IPC::Message& msg); | |
| 47 void OnUnpackExtension(const FilePath& extension_path); | |
| 48 | |
| 49 // IPC messages for web resource service. | |
| 50 void OnUnpackWebResource(const std::string& resource_data); | |
| 51 | |
| 52 // IPC for parsing an extensions auto-update manifest xml file. | |
| 53 void OnParseUpdateManifest(const std::string& xml); | |
| 54 | |
| 55 // IPC for decoding an image. | |
| 56 void OnDecodeImage(const std::vector<unsigned char>& encoded_data); | |
| 57 | |
| 58 // IPC for decoding an image which is base64 encoded. | |
| 59 void OnDecodeImageBase64(const std::string& encoded_data); | |
| 60 | |
| 61 // IPC to render a PDF into a platform metafile. | |
| 62 void OnRenderPDFPagesToMetafile( | |
| 63 base::PlatformFile pdf_file, | |
| 64 const FilePath& metafile_path, | |
| 65 const gfx::Rect& render_area, | |
| 66 int render_dpi, | |
| 67 const std::vector<printing::PageRange>& page_ranges); | |
| 68 | |
| 69 #if defined(OS_WIN) | |
| 70 // Helper method for Windows. | |
| 71 // |highest_rendered_page_number| is set to -1 on failure to render any page. | |
| 72 bool RenderPDFToWinMetafile( | |
| 73 base::PlatformFile pdf_file, | |
| 74 const FilePath& metafile_path, | |
| 75 const gfx::Rect& render_area, | |
| 76 int render_dpi, | |
| 77 const std::vector<printing::PageRange>& page_ranges, | |
| 78 int* highest_rendered_page_number); | |
| 79 #endif // defined(OS_WIN) | |
| 80 | |
| 81 // IPC for extracting IDBKeys from SerializedScriptValues, used by IndexedDB. | |
| 82 void OnIDBKeysFromValuesAndKeyPath( | |
| 83 int id, | |
| 84 const std::vector<SerializedScriptValue>& serialized_script_values, | |
| 85 const string16& idb_key_path); | |
| 86 | |
| 87 // IPC for injecting an IndexedDB key into a SerializedScriptValue. | |
| 88 void OnInjectIDBKey(const IndexedDBKey& key, | |
| 89 const SerializedScriptValue& value, | |
| 90 const string16& key_path); | |
| 91 | |
| 92 // IPC for parsing a string of JSON into a Value. | |
| 93 void OnParseJSON(const std::string& json); | |
| 94 | |
| 95 // IPC to notify we'll be running in batch mode instead of quitting after | |
| 96 // any of the IPCs above, we'll only quit during OnBatchModeFinished(). | |
| 97 void OnBatchModeStarted(); | |
| 98 | |
| 99 // IPC to notify batch mode has finished and we should now quit. | |
| 100 void OnBatchModeFinished(); | |
| 101 | |
| 102 // IPC to get capabilities and defaults for the specified | |
| 103 // printer. Used on Windows to isolate the service process from printer driver | |
| 104 // crashes by executing this in a separate process. This does not run in a | |
| 105 // sandbox. | |
| 106 void OnGetPrinterCapsAndDefaults(const std::string& printer_name); | |
| 107 | |
| 108 // Releases the process if we are not (or no longer) in batch mode. | |
| 109 void ReleaseProcessIfNeeded(); | |
| 110 | |
| 111 // True when we're running in batch mode. | |
| 112 bool batch_mode_; | |
| 113 | |
| 114 DISALLOW_COPY_AND_ASSIGN(UtilityThread); | |
| 115 }; | |
| 116 | |
| 117 #endif // CHROME_UTILITY_UTILITY_THREAD_H_ | |
| OLD | NEW |