Make the ChromeOS chromecast system tray integration use a private API.
[chromium-blink-merge.git] / chrome / browser / process_singleton_startup_lock.h
blob187dd35bce3d95a15b1008331a86f5702665871a
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.
5 #ifndef CHROME_BROWSER_PROCESS_SINGLETON_STARTUP_LOCK_H_
6 #define CHROME_BROWSER_PROCESS_SINGLETON_STARTUP_LOCK_H_
8 #include <set>
9 #include <utility>
10 #include <vector>
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"
18 // Provides a ProcessSingleton::NotificationCallback that can queue up
19 // command-line invocations during startup and execute them when startup
20 // completes.
22 // The object starts in a locked state. |Unlock()| must be called
23 // when the process is prepared to handle command-line invocations.
25 // Once unlocked, notifications are forwarded to a wrapped NotificationCallback.
26 class ProcessSingletonStartupLock : public base::NonThreadSafe {
27 public:
28 explicit ProcessSingletonStartupLock(
29 const ProcessSingleton::NotificationCallback& original_callback);
30 ~ProcessSingletonStartupLock();
32 // Returns the ProcessSingleton::NotificationCallback.
33 // The callback is only valid during the lifetime of the
34 // ProcessSingletonStartupLock instance.
35 ProcessSingleton::NotificationCallback AsNotificationCallback();
37 // Executes previously queued command-line invocations and allows future
38 // invocations to be executed immediately.
39 void Unlock();
41 bool locked() { return locked_; }
43 private:
44 typedef std::pair<base::CommandLine::StringVector, base::FilePath>
45 DelayedStartupMessage;
47 bool NotificationCallbackImpl(const base::CommandLine& command_line,
48 const base::FilePath& current_directory);
50 bool locked_;
51 std::vector<DelayedStartupMessage> saved_startup_messages_;
52 ProcessSingleton::NotificationCallback original_callback_;
54 DISALLOW_COPY_AND_ASSIGN(ProcessSingletonStartupLock);
57 #endif // CHROME_BROWSER_PROCESS_SINGLETON_STARTUP_LOCK_H_