| OLD | NEW |
| 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 #include "chrome/browser/process_singleton_startup_lock.h" | 5 #include "chrome/browser/process_singleton_startup_lock.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 | 9 |
| 10 ProcessSingletonStartupLock::ProcessSingletonStartupLock( | 10 ProcessSingletonStartupLock::ProcessSingletonStartupLock( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 locked_ = false; | 25 locked_ = false; |
| 26 | 26 |
| 27 // Replay the command lines of the messages which were received while the | 27 // Replay the command lines of the messages which were received while the |
| 28 // ProcessSingleton was locked. Only replay each message once. | 28 // ProcessSingleton was locked. Only replay each message once. |
| 29 std::set<DelayedStartupMessage> replayed_messages; | 29 std::set<DelayedStartupMessage> replayed_messages; |
| 30 for (std::vector<DelayedStartupMessage>::const_iterator it = | 30 for (std::vector<DelayedStartupMessage>::const_iterator it = |
| 31 saved_startup_messages_.begin(); | 31 saved_startup_messages_.begin(); |
| 32 it != saved_startup_messages_.end(); ++it) { | 32 it != saved_startup_messages_.end(); ++it) { |
| 33 if (replayed_messages.find(*it) != replayed_messages.end()) | 33 if (replayed_messages.find(*it) != replayed_messages.end()) |
| 34 continue; | 34 continue; |
| 35 original_callback_.Run(CommandLine(it->first), it->second); | 35 original_callback_.Run(base::CommandLine(it->first), it->second); |
| 36 replayed_messages.insert(*it); | 36 replayed_messages.insert(*it); |
| 37 } | 37 } |
| 38 saved_startup_messages_.clear(); | 38 saved_startup_messages_.clear(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 bool ProcessSingletonStartupLock::NotificationCallbackImpl( | 41 bool ProcessSingletonStartupLock::NotificationCallbackImpl( |
| 42 const CommandLine& command_line, | 42 const base::CommandLine& command_line, |
| 43 const base::FilePath& current_directory) { | 43 const base::FilePath& current_directory) { |
| 44 if (locked_) { | 44 if (locked_) { |
| 45 // If locked, it means we are not ready to process this message because | 45 // If locked, it means we are not ready to process this message because |
| 46 // we are probably in a first run critical phase. | 46 // we are probably in a first run critical phase. |
| 47 saved_startup_messages_.push_back( | 47 saved_startup_messages_.push_back( |
| 48 std::make_pair(command_line.argv(), current_directory)); | 48 std::make_pair(command_line.argv(), current_directory)); |
| 49 return true; | 49 return true; |
| 50 } else { | 50 } else { |
| 51 return original_callback_.Run(command_line, current_directory); | 51 return original_callback_.Run(command_line, current_directory); |
| 52 } | 52 } |
| 53 } | 53 } |
| OLD | NEW |