Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1012)

Unified Diff: content/browser/utility_process_host.cc

Issue 6995095: Move UtilityProcessHost to content and move the message sending/dispatching to the clients. This... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/utility_process_host.h ('k') | content/common/content_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/utility_process_host.cc
===================================================================
--- content/browser/utility_process_host.cc (revision 88135)
+++ content/browser/utility_process_host.cc (working copy)
@@ -2,108 +2,53 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/utility_process_host.h"
+#include "content/browser/utility_process_host.h"
#include "base/command_line.h"
-#include "base/file_util.h"
#include "base/message_loop.h"
-#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/utility_messages.h"
-#include "content/common/indexed_db_key.h"
-#include "content/common/serialized_script_value.h"
+#include "content/common/utility_messages.h"
#include "ipc/ipc_switches.h"
-#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/ui_base_switches.h"
-UtilityProcessHost::UtilityProcessHost(Client* client,
- BrowserThread::ID client_thread_id)
- : BrowserChildProcessHost(UTILITY_PROCESS),
- client_(client),
- client_thread_id_(client_thread_id),
- is_batch_mode_(false) {
+UtilityProcessHost::Client::Client() {
}
-UtilityProcessHost::~UtilityProcessHost() {
- DCHECK(!is_batch_mode_);
+UtilityProcessHost::Client::~Client() {
}
-bool UtilityProcessHost::StartExtensionUnpacker(const FilePath& extension) {
- // Grant the subprocess access to the entire subdir the extension file is
- // in, so that it can unpack to that dir.
- if (!StartProcess(extension.DirName()))
- return false;
-
- Send(new UtilityMsg_UnpackExtension(extension));
- return true;
+void UtilityProcessHost::Client::OnProcessCrashed(int exit_code) {
}
-bool UtilityProcessHost::StartWebResourceUnpacker(const std::string& data) {
- if (!StartProcess(FilePath()))
- return false;
-
- Send(new UtilityMsg_UnpackWebResource(data));
- return true;
+bool UtilityProcessHost::Client::OnMessageReceived(
+ const IPC::Message& message) {
+ return false;
}
-bool UtilityProcessHost::StartUpdateManifestParse(const std::string& xml) {
- if (!StartProcess(FilePath()))
- return false;
-
- Send(new UtilityMsg_ParseUpdateManifest(xml));
- return true;
+UtilityProcessHost::UtilityProcessHost(Client* client,
+ BrowserThread::ID client_thread_id)
+ : BrowserChildProcessHost(UTILITY_PROCESS),
+ client_(client),
+ client_thread_id_(client_thread_id),
+ is_batch_mode_(false),
+ started_(false) {
}
-bool UtilityProcessHost::StartImageDecoding(
- const std::vector<unsigned char>& encoded_data) {
- if (!StartProcess(FilePath()))
- return false;
-
- Send(new UtilityMsg_DecodeImage(encoded_data));
- return true;
+UtilityProcessHost::~UtilityProcessHost() {
+ DCHECK(!is_batch_mode_);
}
-bool UtilityProcessHost::StartImageDecodingBase64(
- const std::string& base64_encoded_data) {
- if (!StartProcess(FilePath()))
+bool UtilityProcessHost::Send(IPC::Message* message) {
+ if (!StartProcess())
return false;
- Send(new UtilityMsg_DecodeImageBase64(base64_encoded_data));
- return true;
+ return BrowserChildProcessHost::Send(message);
}
-bool UtilityProcessHost::StartIDBKeysFromValuesAndKeyPath(
- int id, const std::vector<SerializedScriptValue>& serialized_values,
- const string16& key_path) {
- if (!StartProcess(FilePath()))
- return false;
-
- Send(new UtilityMsg_IDBKeysFromValuesAndKeyPath(
- id, serialized_values, key_path));
- return true;
-}
-
-bool UtilityProcessHost::StartInjectIDBKey(
- const IndexedDBKey& key, const SerializedScriptValue& value,
- const string16& key_path) {
- if (!StartProcess(FilePath()))
- return false;
-
- Send(new UtilityMsg_InjectIDBKey(key, value, key_path));
- return true;
-}
-
-bool UtilityProcessHost::StartJSONParsing(const std::string& json) {
- if (!StartProcess(FilePath()))
- return false;
- Send(new UtilityMsg_ParseJSON(json));
- return true;
-}
-
bool UtilityProcessHost::StartBatchMode() {
CHECK(!is_batch_mode_);
- is_batch_mode_ = StartProcess(FilePath());
+ is_batch_mode_ = StartProcess();
Send(new UtilityMsg_BatchMode_Started());
return is_batch_mode_;
}
@@ -118,7 +63,11 @@
return GetChildPath(true);
}
-bool UtilityProcessHost::StartProcess(const FilePath& exposed_dir) {
+bool UtilityProcessHost::StartProcess() {
+ if (started_)
+ return true;
+ started_ = true;
Matt Perry 2011/06/09 20:54:49 we should only set this at the end of the method,
jam 2011/06/09 21:13:45 I think it doesn't matter either way, because if i
+
if (is_batch_mode_)
return true;
// Name must be set or metrics_service will crash in any test which
@@ -164,12 +113,12 @@
switches::kUtilityCmdPrefix));
}
- cmd_line->AppendSwitchPath(switches::kUtilityProcessAllowedDir, exposed_dir);
+ cmd_line->AppendSwitchPath(switches::kUtilityProcessAllowedDir, exposed_dir_);
#endif
Launch(
#if defined(OS_WIN)
- exposed_dir,
+ exposed_dir_,
#elif defined(OS_POSIX)
false,
base::environment_vector(),
@@ -195,38 +144,3 @@
bool UtilityProcessHost::CanShutdown() {
return true;
}
-
-bool UtilityProcessHost::Client::OnMessageReceived(
- const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(UtilityProcessHost, message)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackExtension_Succeeded,
- Client::OnUnpackExtensionSucceeded)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackExtension_Failed,
- Client::OnUnpackExtensionFailed)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackWebResource_Succeeded,
- Client::OnUnpackWebResourceSucceeded)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackWebResource_Failed,
- Client::OnUnpackWebResourceFailed)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseUpdateManifest_Succeeded,
- Client::OnParseUpdateManifestSucceeded)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseUpdateManifest_Failed,
- Client::OnParseUpdateManifestFailed)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_DecodeImage_Succeeded,
- Client::OnDecodeImageSucceeded)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_DecodeImage_Failed,
- Client::OnDecodeImageFailed)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Succeeded,
- Client::OnIDBKeysFromValuesAndKeyPathSucceeded)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Failed,
- Client::OnIDBKeysFromValuesAndKeyPathFailed)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_InjectIDBKey_Finished,
- Client::OnInjectIDBKeyFinished)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseJSON_Succeeded,
- Client::OnJSONParseSucceeded)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseJSON_Failed,
- Client::OnJSONParseFailed)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP_EX()
- return handled;
-}
« no previous file with comments | « content/browser/utility_process_host.h ('k') | content/common/content_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698