summaryrefslogtreecommitdiffstats
path: root/chrome/browser/utility_process_host.h
diff options
context:
space:
mode:
authormpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 22:23:43 +0000
committermpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 22:23:43 +0000
commit1fca149ca717c64ae05edb534a61a909dc0a6d11 (patch)
tree6972a9efe49eba842a77cdeb98be8ac2caba8d27 /chrome/browser/utility_process_host.h
parent20a85780ae0ae9b8467b10146044fec8c1144e77 (diff)
downloadchromium_src-1fca149ca717c64ae05edb534a61a909dc0a6d11.zip
chromium_src-1fca149ca717c64ae05edb534a61a909dc0a6d11.tar.gz
chromium_src-1fca149ca717c64ae05edb534a61a909dc0a6d11.tar.bz2
Introducing the Utility process, which handles the unpacking and verification
of extension packages. This is a first pass. In the second pass, I will add support for transcoding the manifest and any images in the browser process. BUG=11680 Review URL: http://codereview.chromium.org/114027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/utility_process_host.h')
-rw-r--r--chrome/browser/utility_process_host.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/chrome/browser/utility_process_host.h b/chrome/browser/utility_process_host.h
new file mode 100644
index 0000000..8cb281e
--- /dev/null
+++ b/chrome/browser/utility_process_host.h
@@ -0,0 +1,79 @@
+// 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_BROWSER_UTILITY_PROCESS_HOST_H_
+#define CHROME_BROWSER_UTILITY_PROCESS_HOST_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/ref_counted.h"
+#include "base/task.h"
+#include "chrome/common/child_process_host.h"
+#include "chrome/common/ipc_channel.h"
+
+class CommandLine;
+class MessageLoop;
+
+// This class acts as the browser-side host to a utility child process. A
+// utility process is a short-lived sandboxed process that is created to run
+// a specific task. This class lives solely on the IO thread.
+class UtilityProcessHost : public ChildProcessHost {
+ public:
+ // An interface to be implemented by consumers of the utility process to
+ // get results back. All functions are called on the thread passed along
+ // to UtilityProcessHost.
+ class Client : public base::RefCountedThreadSafe<Client> {
+ public:
+ Client() {}
+ virtual ~Client() {}
+
+ // Called when the process has crashed.
+ virtual void OnProcessCrashed() {}
+
+ // Called when the process sends a reply to an UnpackExtension message.
+ // If success if false, error_message contains a description of the problem.
+ virtual void OnUnpackExtensionReply(bool success,
+ const std::string& error_message) {}
+ private:
+ friend class UtilityProcessHost;
+ void OnMessageReceived(const IPC::Message& message);
+
+ DISALLOW_COPY_AND_ASSIGN(Client);
+ };
+
+ UtilityProcessHost(ResourceDispatcherHost* rdh, Client* client,
+ MessageLoop* client_loop);
+ ~UtilityProcessHost();
+
+ // Start a process to unpack the extension at the given path. The process
+ // will be given access to the directory subtree that the extension file is
+ // in, so the caller is expected to have moved that file into a quarantined
+ // location first.
+ bool StartExtensionUnpacker(const FilePath& extension);
+
+ private:
+ // Starts the process. Returns true iff it succeeded.
+ bool StartProcess(const FilePath& exposed_dir);
+
+ // IPC messages:
+ void OnMessageReceived(const IPC::Message& message);
+
+ // ChildProcessHost:
+ virtual void OnChannelError();
+ virtual bool CanShutdown() { return true; }
+ virtual URLRequestContext* GetRequestContext(
+ uint32 request_id,
+ const ViewHostMsg_Resource_Request& request_data) {
+ return NULL;
+ }
+
+ // A pointer to our client interface, who will be informed of progress.
+ scoped_refptr<Client> client_;
+ MessageLoop* client_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(UtilityProcessHost);
+};
+
+#endif // CHROME_BROWSER_UTILITY_PROCESS_HOST_H_