[M120][Tizen][Onscreen] Fix build errors for TV profile
[platform/framework/web/chromium-efl.git] / chrome / browser / process_singleton_startup_lock.h
1 // Copyright 2013 The Chromium Authors
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_STARTUP_LOCK_H_
6 #define CHROME_BROWSER_PROCESS_SINGLETON_STARTUP_LOCK_H_
7
8 #include <set>
9 #include <utility>
10 #include <vector>
11
12 #include "base/command_line.h"
13 #include "base/files/file_path.h"
14 #include "base/sequence_checker.h"
15 #include "chrome/browser/process_singleton.h"
16
17 // Provides a ProcessSingleton::NotificationCallback that can queue up
18 // command-line invocations during startup and execute them when startup
19 // completes.
20 //
21 // The object starts in a locked state. |Unlock()| must be called
22 // when the process is prepared to handle command-line invocations.
23 //
24 // Once unlocked, notifications are forwarded to a wrapped NotificationCallback.
25 class ProcessSingletonStartupLock {
26  public:
27   explicit ProcessSingletonStartupLock(
28       const ProcessSingleton::NotificationCallback& original_callback);
29
30   ProcessSingletonStartupLock(const ProcessSingletonStartupLock&) = delete;
31   ProcessSingletonStartupLock& operator=(const ProcessSingletonStartupLock&) =
32       delete;
33
34   ~ProcessSingletonStartupLock();
35
36   // Returns the ProcessSingleton::NotificationCallback.
37   // The callback is only valid during the lifetime of the
38   // ProcessSingletonStartupLock instance.
39   ProcessSingleton::NotificationCallback AsNotificationCallback();
40
41   // Executes previously queued command-line invocations and allows future
42   // invocations to be executed immediately.
43   void Unlock();
44
45   bool locked() { return locked_; }
46
47  private:
48   typedef std::pair<base::CommandLine::StringVector, base::FilePath>
49       DelayedStartupMessage;
50
51   bool NotificationCallbackImpl(const base::CommandLine& command_line,
52                                 const base::FilePath& current_directory);
53
54   bool locked_;
55   std::vector<DelayedStartupMessage> saved_startup_messages_;
56   ProcessSingleton::NotificationCallback original_callback_;
57
58   SEQUENCE_CHECKER(sequence_checker_);
59 };
60
61 #endif  // CHROME_BROWSER_PROCESS_SINGLETON_STARTUP_LOCK_H_