Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 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 #ifndef CHROME_BROWSER_PROCESS_SINGLETON_LOCK_H_ | |
| 6 #define CHROME_BROWSER_PROCESS_SINGLETON_LOCK_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 #include <utility> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/command_line.h" | |
| 14 #include "base/files/file_path.h" | |
| 15 #include "base/threading/non_thread_safe.h" | |
| 16 #include "chrome/browser/process_singleton.h" | |
| 17 | |
| 18 // Implements a ProcessSingleton::NotificationCallback that can queue up | |
|
gab
2013/03/27 18:03:26
Same comment here about "Implements".
erikwright (departed)
2013/03/28 03:16:34
Done.
| |
| 19 // command-line invocations during startup and execute them when startup | |
| 20 // completes. The object starts in a locked state. |Unlock()| must be called | |
| 21 // when the process is prepared to handle command-line invocations. | |
| 22 // | |
| 23 // Once unlocked, notifications are forwarded to a wrapped NotificationCallback. | |
| 24 class ProcessSingletonLock : public base::NonThreadSafe { | |
|
gab
2013/03/27 18:03:26
Add to the documentation that ProcessSingletonLock
erikwright (departed)
2013/03/27 18:28:44
Is the comment on line 20 ("The object starts in a
gab
2013/03/27 18:33:20
Oh, I did overlook that, although I read the comme
erikwright (departed)
2013/03/28 03:16:34
Done.
| |
| 25 public: | |
| 26 explicit ProcessSingletonLock( | |
| 27 const ProcessSingleton::NotificationCallback& original_callback); | |
| 28 ~ProcessSingletonLock(); | |
| 29 | |
| 30 // Returns the callback that should be supplied to ProcessSingleton. | |
| 31 // The callback is only valid during the lifetime of the ProcessSingletonLock | |
| 32 // instance. | |
| 33 ProcessSingleton::NotificationCallback AsNotificationCallback(); | |
| 34 | |
| 35 // Executes previously queued command-line invocations and allows future | |
| 36 // invocations to be executed immediately. | |
| 37 void Unlock(); | |
| 38 | |
| 39 bool locked() { return locked_; } | |
| 40 | |
| 41 private: | |
| 42 typedef std::pair<CommandLine::StringVector, base::FilePath> | |
| 43 DelayedStartupMessage; | |
| 44 | |
| 45 bool NotificationCallbackImpl(const CommandLine& command_line, | |
| 46 const base::FilePath& current_directory); | |
| 47 | |
| 48 bool locked_; | |
| 49 std::vector<DelayedStartupMessage> saved_startup_messages_; | |
| 50 ProcessSingleton::NotificationCallback original_callback_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(ProcessSingletonLock); | |
| 53 }; | |
| 54 | |
| 55 #endif // CHROME_BROWSER_PROCESS_SINGLETON_LOCK_H_ | |
| OLD | NEW |