OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2006-2008 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 #include <windows.h> |
| 6 #include "chrome/worker/worker_process.h" |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/scoped_handle.h" |
| 10 #include "chrome/common/ipc_channel.h" |
| 11 #include "chrome/common/ipc_message_utils.h" |
| 12 #include "chrome/common/worker_messages.h" |
| 13 |
| 14 // Custom factory to allow us to pass additional ctor arguments. |
| 15 class WorkerProcessFactory : public ChildProcessFactoryInterface { |
| 16 public: |
| 17 explicit WorkerProcessFactory() {} |
| 18 |
| 19 virtual ChildProcess* Create(const std::wstring& channel_name) { |
| 20 return new WorkerProcess(channel_name); |
| 21 } |
| 22 }; |
| 23 |
| 24 |
| 25 // No AddRef required when using WorkerProcess with RunnableMethod. This is |
| 26 // okay since the lifetime of the WorkerProcess is always greater than the |
| 27 // lifetime of WorkerThread because it's a member variable. |
| 28 template <> struct RunnableMethodTraits<WorkerProcess> { |
| 29 static void RetainCallee(WorkerProcess*) {} |
| 30 static void ReleaseCallee(WorkerProcess*) {} |
| 31 }; |
| 32 |
| 33 WorkerProcess::WorkerProcess(const std::wstring& channel_name) : |
| 34 #pragma warning(suppress: 4355) // Okay to pass "this" here. |
| 35 worker_thread_(this, channel_name) { |
| 36 } |
| 37 |
| 38 WorkerProcess::~WorkerProcess() { |
| 39 } |
| 40 |
| 41 bool WorkerProcess::GlobalInit(const std::wstring &channel_name) { |
| 42 WorkerProcessFactory factory; |
| 43 return ChildProcess::GlobalInit(channel_name, &factory); |
| 44 } |
| 45 |
| 46 |
| 47 // Note: may be called on any thread |
| 48 void WorkerProcess::OnFinalRelease() { |
| 49 } |
OLD | NEW |