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