OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include "chrome/common/child_process.h" | 7 #include "chrome/common/child_process.h" |
8 | 8 |
9 #include "base/atomic_ref_count.h" | 9 #include "base/atomic_ref_count.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 // Remember the current message loop, so we can communicate with this thread | 73 // Remember the current message loop, so we can communicate with this thread |
74 // again when we need to shutdown (see ReleaseProcess). | 74 // again when we need to shutdown (see ReleaseProcess). |
75 main_thread_loop_ = MessageLoop::current(); | 75 main_thread_loop_ = MessageLoop::current(); |
76 | 76 |
77 // An event that will be signalled when we shutdown. | 77 // An event that will be signalled when we shutdown. |
78 shutdown_event_ = new base::WaitableEvent(true, false); | 78 shutdown_event_ = new base::WaitableEvent(true, false); |
79 | 79 |
80 child_process_ = factory->Create(channel_name); | 80 child_process_ = factory->Create(channel_name); |
81 | 81 |
82 CommandLine command_line; | 82 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
83 if (command_line.HasSwitch(switches::kUserAgent)) { | 83 if (command_line.HasSwitch(switches::kUserAgent)) { |
84 webkit_glue::SetUserAgent(WideToUTF8( | 84 webkit_glue::SetUserAgent(WideToUTF8( |
85 command_line.GetSwitchValue(switches::kUserAgent))); | 85 command_line.GetSwitchValue(switches::kUserAgent))); |
86 } | 86 } |
87 | 87 |
88 return true; | 88 return true; |
89 } | 89 } |
90 | 90 |
91 void ChildProcess::GlobalCleanup() { | 91 void ChildProcess::GlobalCleanup() { |
92 // Signal this event before destroying the child process. That way all | 92 // Signal this event before destroying the child process. That way all |
93 // background threads. | 93 // background threads. |
94 // For example, in the renderer the RenderThread instances will be able to | 94 // For example, in the renderer the RenderThread instances will be able to |
95 // notice shutdown before the render process begins waiting for them to exit. | 95 // notice shutdown before the render process begins waiting for them to exit. |
96 shutdown_event_->Signal(); | 96 shutdown_event_->Signal(); |
97 | 97 |
98 // Destroy the child process first to force all background threads to | 98 // Destroy the child process first to force all background threads to |
99 // terminate before we bring down other resources. (We null pointers | 99 // terminate before we bring down other resources. (We null pointers |
100 // just in case.) | 100 // just in case.) |
101 child_process_->Cleanup(); | 101 child_process_->Cleanup(); |
102 delete child_process_; | 102 delete child_process_; |
103 child_process_ = NULL; | 103 child_process_ = NULL; |
104 | 104 |
105 main_thread_loop_ = NULL; | 105 main_thread_loop_ = NULL; |
106 | 106 |
107 delete shutdown_event_; | 107 delete shutdown_event_; |
108 shutdown_event_ = NULL; | 108 shutdown_event_ = NULL; |
109 } | 109 } |
110 | 110 |
OLD | NEW |