OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/service_process_util.h" | 5 #include "chrome/common/service_process_util.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #endif | 44 #endif |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 bool g_good_shutdown = false; | 48 bool g_good_shutdown = false; |
49 | 49 |
50 void ShutdownTask(MessageLoop* loop) { | 50 void ShutdownTask(MessageLoop* loop) { |
51 // Quit the main message loop. | 51 // Quit the main message loop. |
52 ASSERT_FALSE(g_good_shutdown); | 52 ASSERT_FALSE(g_good_shutdown); |
53 g_good_shutdown = true; | 53 g_good_shutdown = true; |
54 loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 54 loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
55 } | 55 } |
56 | 56 |
57 } // namespace | 57 } // namespace |
58 | 58 |
59 TEST(ServiceProcessUtilTest, ScopedVersionedName) { | 59 TEST(ServiceProcessUtilTest, ScopedVersionedName) { |
60 std::string test_str = "test"; | 60 std::string test_str = "test"; |
61 std::string scoped_name = GetServiceProcessScopedVersionedName(test_str); | 61 std::string scoped_name = GetServiceProcessScopedVersionedName(test_str); |
62 chrome::VersionInfo version_info; | 62 chrome::VersionInfo version_info; |
63 DCHECK(version_info.is_valid()); | 63 DCHECK(version_info.is_valid()); |
64 EXPECT_TRUE(EndsWith(scoped_name, test_str, true)); | 64 EXPECT_TRUE(EndsWith(scoped_name, test_str, true)); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 message_loop.set_thread_name("ServiceProcessStateTestShutdownMainThread"); | 220 message_loop.set_thread_name("ServiceProcessStateTestShutdownMainThread"); |
221 base::Thread io_thread_("ServiceProcessStateTestShutdownIOThread"); | 221 base::Thread io_thread_("ServiceProcessStateTestShutdownIOThread"); |
222 base::Thread::Options options(MessageLoop::TYPE_IO, 0); | 222 base::Thread::Options options(MessageLoop::TYPE_IO, 0); |
223 EXPECT_TRUE(io_thread_.StartWithOptions(options)); | 223 EXPECT_TRUE(io_thread_.StartWithOptions(options)); |
224 ServiceProcessState state; | 224 ServiceProcessState state; |
225 EXPECT_TRUE(state.Initialize()); | 225 EXPECT_TRUE(state.Initialize()); |
226 EXPECT_TRUE(state.SignalReady(io_thread_.message_loop_proxy(), | 226 EXPECT_TRUE(state.SignalReady(io_thread_.message_loop_proxy(), |
227 base::Bind(&ShutdownTask, | 227 base::Bind(&ShutdownTask, |
228 MessageLoop::current()))); | 228 MessageLoop::current()))); |
229 message_loop.PostDelayedTask(FROM_HERE, | 229 message_loop.PostDelayedTask(FROM_HERE, |
230 new MessageLoop::QuitTask(), | 230 MessageLoop::QuitClosure(), |
231 TestTimeouts::action_max_timeout_ms()); | 231 TestTimeouts::action_max_timeout_ms()); |
232 EXPECT_FALSE(g_good_shutdown); | 232 EXPECT_FALSE(g_good_shutdown); |
233 message_loop.Run(); | 233 message_loop.Run(); |
234 EXPECT_TRUE(g_good_shutdown); | 234 EXPECT_TRUE(g_good_shutdown); |
235 return 0; | 235 return 0; |
236 } | 236 } |
237 | 237 |
238 #else // !OS_MACOSX | 238 #else // !OS_MACOSX |
239 | 239 |
240 #include <CoreFoundation/CoreFoundation.h> | 240 #include <CoreFoundation/CoreFoundation.h> |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 return CFDictionaryCreate(kCFAllocatorDefault, | 298 return CFDictionaryCreate(kCFAllocatorDefault, |
299 keys, | 299 keys, |
300 values, | 300 values, |
301 arraysize(keys), | 301 arraysize(keys), |
302 &kCFTypeDictionaryKeyCallBacks, | 302 &kCFTypeDictionaryKeyCallBacks, |
303 &kCFTypeDictionaryValueCallBacks); | 303 &kCFTypeDictionaryValueCallBacks); |
304 } | 304 } |
305 | 305 |
306 virtual bool RemoveJob(CFStringRef label, CFErrorRef* error) OVERRIDE { | 306 virtual bool RemoveJob(CFStringRef label, CFErrorRef* error) OVERRIDE { |
307 remove_called_ = true; | 307 remove_called_ = true; |
308 message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask); | 308 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
309 return true; | 309 return true; |
310 } | 310 } |
311 | 311 |
312 virtual bool RestartJob(Domain domain, | 312 virtual bool RestartJob(Domain domain, |
313 Type type, | 313 Type type, |
314 CFStringRef name, | 314 CFStringRef name, |
315 CFStringRef session_type) OVERRIDE { | 315 CFStringRef session_type) OVERRIDE { |
316 restart_called_ = true; | 316 restart_called_ = true; |
317 message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask); | 317 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
318 return true; | 318 return true; |
319 } | 319 } |
320 | 320 |
321 virtual CFMutableDictionaryRef CreatePlistFromFile( | 321 virtual CFMutableDictionaryRef CreatePlistFromFile( |
322 Domain domain, | 322 Domain domain, |
323 Type type, | 323 Type type, |
324 CFStringRef name) OVERRIDE { | 324 CFStringRef name) OVERRIDE { |
325 base::mac::ScopedCFTypeRef<CFDictionaryRef> dict( | 325 base::mac::ScopedCFTypeRef<CFDictionaryRef> dict( |
326 CopyDictionaryByCheckingIn(NULL)); | 326 CopyDictionaryByCheckingIn(NULL)); |
327 return CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, dict); | 327 return CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, dict); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 &bundle_path_, | 375 &bundle_path_, |
376 &executable_path_)); | 376 &executable_path_)); |
377 mock_launchd_.reset(new MockLaunchd(executable_path_, &loop_)); | 377 mock_launchd_.reset(new MockLaunchd(executable_path_, &loop_)); |
378 scoped_launchd_instance_.reset( | 378 scoped_launchd_instance_.reset( |
379 new Launchd::ScopedInstance(mock_launchd_.get())); | 379 new Launchd::ScopedInstance(mock_launchd_.get())); |
380 ASSERT_TRUE(service_process_state_.Initialize()); | 380 ASSERT_TRUE(service_process_state_.Initialize()); |
381 ASSERT_TRUE(service_process_state_.SignalReady( | 381 ASSERT_TRUE(service_process_state_.SignalReady( |
382 io_thread_.message_loop_proxy(), | 382 io_thread_.message_loop_proxy(), |
383 base::Closure())); | 383 base::Closure())); |
384 loop_.PostDelayedTask(FROM_HERE, | 384 loop_.PostDelayedTask(FROM_HERE, |
385 new MessageLoop::QuitTask, | 385 MessageLoop::QuitClosure(), |
386 TestTimeouts::action_max_timeout_ms()); | 386 TestTimeouts::action_max_timeout_ms()); |
387 } | 387 } |
388 | 388 |
389 bool MakeABundle(const FilePath& dst, | 389 bool MakeABundle(const FilePath& dst, |
390 const std::string& name, | 390 const std::string& name, |
391 FilePath* bundle_root, | 391 FilePath* bundle_root, |
392 FilePath* executable) { | 392 FilePath* executable) { |
393 *bundle_root = dst.Append(name + std::string(".app")); | 393 *bundle_root = dst.Append(name + std::string(".app")); |
394 FilePath contents = bundle_root->AppendASCII("Contents"); | 394 FilePath contents = bundle_root->AppendASCII("Contents"); |
395 FilePath mac_os = contents.AppendASCII("MacOS"); | 395 FilePath mac_os = contents.AppendASCII("MacOS"); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 ScopedAttributesRestorer restorer(bundle_path(), 0777); | 575 ScopedAttributesRestorer restorer(bundle_path(), 0777); |
576 GetIOMessageLoopProxy()->PostTask( | 576 GetIOMessageLoopProxy()->PostTask( |
577 FROM_HERE, | 577 FROM_HERE, |
578 base::Bind(&ChangeAttr, bundle_path(), 0222)); | 578 base::Bind(&ChangeAttr, bundle_path(), 0222)); |
579 Run(); | 579 Run(); |
580 ASSERT_TRUE(mock_launchd()->remove_called()); | 580 ASSERT_TRUE(mock_launchd()->remove_called()); |
581 ASSERT_TRUE(mock_launchd()->delete_called()); | 581 ASSERT_TRUE(mock_launchd()->delete_called()); |
582 } | 582 } |
583 | 583 |
584 #endif // !OS_MACOSX | 584 #endif // !OS_MACOSX |
OLD | NEW |