Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: chrome/browser/process_singleton_startup_lock.h

Issue 12674028: Report text output and exit code for command-line operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Forgotten review responses. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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_BROWSER_PROCESS_SINGLETON_STARTUP_LOCK_H_ 5 #ifndef CHROME_BROWSER_PROCESS_SINGLETON_STARTUP_LOCK_H_
6 #define CHROME_BROWSER_PROCESS_SINGLETON_STARTUP_LOCK_H_ 6 #define CHROME_BROWSER_PROCESS_SINGLETON_STARTUP_LOCK_H_
7 7
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/threading/non_thread_safe.h" 15 #include "base/threading/non_thread_safe.h"
16 #include "chrome/browser/process_singleton.h" 16 #include "chrome/browser/process_singleton.h"
17 17
18 class OperationOutput;
19
18 // Provides a ProcessSingleton::NotificationCallback that can queue up 20 // Provides a ProcessSingleton::NotificationCallback that can queue up
19 // command-line invocations during startup and execute them when startup 21 // command-line invocations during startup and execute them when startup
20 // completes. 22 // completes.
21 // 23 //
22 // The object starts in a locked state. |Unlock()| must be called 24 // The object starts in a locked state. |Unlock()| must be called
23 // when the process is prepared to handle command-line invocations. 25 // when the process is prepared to handle command-line invocations.
24 // 26 //
25 // Once unlocked, notifications are forwarded to a wrapped NotificationCallback. 27 // Once unlocked, notifications are forwarded to a wrapped NotificationCallback.
26 class ProcessSingletonStartupLock : public base::NonThreadSafe { 28 class ProcessSingletonStartupLock : public base::NonThreadSafe {
27 public: 29 public:
30 typedef base::Callback<bool(const CommandLine& command_line,
31 const base::FilePath& current_directory,
32 scoped_ptr<OperationOutput> operation_output)>
33 OperationCallback;
34
28 explicit ProcessSingletonStartupLock( 35 explicit ProcessSingletonStartupLock(
29 const ProcessSingleton::NotificationCallback& original_callback); 36 const OperationCallback& operation_callback);
30 ~ProcessSingletonStartupLock(); 37 ~ProcessSingletonStartupLock();
31 38
32 // Returns the ProcessSingleton::NotificationCallback. 39 // Returns the ProcessSingleton::NotificationCallback.
33 // The callback is only valid during the lifetime of the 40 // The callback is only valid during the lifetime of the
34 // ProcessSingletonStartupLock instance. 41 // ProcessSingletonStartupLock instance.
35 ProcessSingleton::NotificationCallback AsNotificationCallback(); 42 ProcessSingleton::NotificationCallback AsNotificationCallback();
36 43
37 // Executes previously queued command-line invocations and allows future 44 // Executes previously queued command-line invocations and allows future
38 // invocations to be executed immediately. 45 // invocations to be executed immediately.
39 void Unlock(); 46 void Unlock();
40 47
41 bool locked() { return locked_; } 48 bool locked() { return locked_; }
42 49
43 private: 50 private:
44 typedef std::pair<CommandLine::StringVector, base::FilePath> 51 struct DelayedStartupMessage {
45 DelayedStartupMessage; 52 DelayedStartupMessage(const CommandLine::StringVector& argv,
53 const base::FilePath& current_directory,
54 OperationOutput* operation_output);
55 ~DelayedStartupMessage();
56
57 CommandLine::StringVector argv_;
58 base::FilePath current_directory_;
59 OperationOutput* operation_output_;
60 };
46 61
47 bool NotificationCallbackImpl(const CommandLine& command_line, 62 bool NotificationCallbackImpl(const CommandLine& command_line,
48 const base::FilePath& current_directory); 63 const base::FilePath& current_directory);
49 64
50 bool locked_; 65 bool locked_;
51 std::vector<DelayedStartupMessage> saved_startup_messages_; 66 std::vector<DelayedStartupMessage> saved_startup_messages_;
52 ProcessSingleton::NotificationCallback original_callback_; 67 OperationCallback operation_callback_;
53 68
54 DISALLOW_COPY_AND_ASSIGN(ProcessSingletonStartupLock); 69 DISALLOW_COPY_AND_ASSIGN(ProcessSingletonStartupLock);
55 }; 70 };
56 71
57 #endif // CHROME_BROWSER_PROCESS_SINGLETON_STARTUP_LOCK_H_ 72 #endif // CHROME_BROWSER_PROCESS_SINGLETON_STARTUP_LOCK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698