Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_COMMON_MAC_MOCK_LAUNCHD_H_ | 5 #ifndef CHROME_COMMON_MAC_MOCK_LAUNCHD_H_ |
| 6 #define CHROME_COMMON_MAC_MOCK_LAUNCHD_H_ | 6 #define CHROME_COMMON_MAC_MOCK_LAUNCHD_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <launch.h> | 9 #include <launch.h> |
| 10 #include <string> | |
|
Mark Mentovai
2012/01/20 20:41:35
Blank line before.
| |
| 10 | 11 |
| 11 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 12 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 13 #include "chrome/common/mac/launchd.h" | 15 #include "chrome/common/mac/launchd.h" |
| 16 #include "chrome/common/multi_process_lock.h" | |
| 14 | 17 |
| 15 class MessageLoop; | 18 class MessageLoop; |
| 16 | 19 |
| 17 // TODO(dmaclach): Write this in terms of a real mock. | 20 // TODO(dmaclach): Write this in terms of a real mock. |
| 18 // http://crbug.com/76923 | 21 // http://crbug.com/76923 |
| 19 class MockLaunchd : public Launchd { | 22 class MockLaunchd : public Launchd { |
| 20 public: | 23 public: |
| 21 static bool MakeABundle(const FilePath& dst, | 24 static bool MakeABundle(const FilePath& dst, |
| 22 const std::string& name, | 25 const std::string& name, |
| 23 FilePath* bundle_root, | 26 FilePath* bundle_root, |
| 24 FilePath* executable); | 27 FilePath* executable); |
| 25 | 28 |
| 26 MockLaunchd(const FilePath& file, MessageLoop* loop) | 29 MockLaunchd(const FilePath& file, MessageLoop* loop, |
| 27 : file_(file), | 30 bool create_socket, bool as_service); |
| 28 message_loop_(loop), | 31 virtual ~MockLaunchd(); |
| 29 restart_called_(false), | |
| 30 remove_called_(false), | |
| 31 checkin_called_(false), | |
| 32 write_called_(false), | |
| 33 delete_called_(false) { | |
| 34 } | |
| 35 virtual ~MockLaunchd() { } | |
| 36 | 32 |
| 37 virtual CFDictionaryRef CopyExports() OVERRIDE; | 33 virtual CFDictionaryRef CopyExports() OVERRIDE; |
| 38 virtual CFDictionaryRef CopyJobDictionary(CFStringRef label) OVERRIDE; | 34 virtual CFDictionaryRef CopyJobDictionary(CFStringRef label) OVERRIDE; |
| 39 virtual CFDictionaryRef CopyDictionaryByCheckingIn(CFErrorRef* error) | 35 virtual CFDictionaryRef CopyDictionaryByCheckingIn(CFErrorRef* error) |
| 40 OVERRIDE; | 36 OVERRIDE; |
| 41 virtual bool RemoveJob(CFStringRef label, CFErrorRef* error) OVERRIDE; | 37 virtual bool RemoveJob(CFStringRef label, CFErrorRef* error) OVERRIDE; |
| 42 virtual bool RestartJob(Domain domain, | 38 virtual bool RestartJob(Domain domain, |
| 43 Type type, | 39 Type type, |
| 44 CFStringRef name, | 40 CFStringRef name, |
| 45 CFStringRef session_type) OVERRIDE; | 41 CFStringRef session_type) OVERRIDE; |
| 46 virtual CFMutableDictionaryRef CreatePlistFromFile( | 42 virtual CFMutableDictionaryRef CreatePlistFromFile( |
| 47 Domain domain, | 43 Domain domain, |
| 48 Type type, | 44 Type type, |
| 49 CFStringRef name) OVERRIDE; | 45 CFStringRef name) OVERRIDE; |
| 50 virtual bool WritePlistToFile(Domain domain, | 46 virtual bool WritePlistToFile(Domain domain, |
| 51 Type type, | 47 Type type, |
| 52 CFStringRef name, | 48 CFStringRef name, |
| 53 CFDictionaryRef dict) OVERRIDE; | 49 CFDictionaryRef dict) OVERRIDE; |
| 54 virtual bool DeletePlist(Domain domain, | 50 virtual bool DeletePlist(Domain domain, |
| 55 Type type, | 51 Type type, |
| 56 CFStringRef name) OVERRIDE; | 52 CFStringRef name) OVERRIDE; |
| 57 | 53 |
| 54 void SignalReady(); | |
| 55 | |
| 58 bool restart_called() const { return restart_called_; } | 56 bool restart_called() const { return restart_called_; } |
| 59 bool remove_called() const { return remove_called_; } | 57 bool remove_called() const { return remove_called_; } |
| 60 bool checkin_called() const { return checkin_called_; } | 58 bool checkin_called() const { return checkin_called_; } |
| 61 bool write_called() const { return write_called_; } | 59 bool write_called() const { return write_called_; } |
| 62 bool delete_called() const { return delete_called_; } | 60 bool delete_called() const { return delete_called_; } |
| 63 | 61 |
| 64 private: | 62 private: |
| 65 FilePath file_; | 63 FilePath file_; |
| 64 std::string pipe_name_; | |
| 66 MessageLoop* message_loop_; | 65 MessageLoop* message_loop_; |
| 66 scoped_ptr<MultiProcessLock> running_lock_; | |
| 67 bool create_socket_; | |
| 68 bool as_service_; | |
| 67 bool restart_called_; | 69 bool restart_called_; |
| 68 bool remove_called_; | 70 bool remove_called_; |
| 71 bool job_called_; | |
| 69 bool checkin_called_; | 72 bool checkin_called_; |
| 70 bool write_called_; | 73 bool write_called_; |
| 71 bool delete_called_; | 74 bool delete_called_; |
| 72 }; | 75 }; |
| 73 | 76 |
| 74 #endif // CHROME_COMMON_MAC_MOCK_LAUNCHD_H_ | 77 #endif // CHROME_COMMON_MAC_MOCK_LAUNCHD_H_ |
| OLD | NEW |