| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_browser_main_posix.h" | 5 #include "chrome/browser/chrome_browser_main_posix.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <limits.h> | 8 #include <limits.h> |
| 9 #include <pthread.h> | 9 #include <pthread.h> |
| 10 #include <signal.h> | 10 #include <signal.h> |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 class ExitHandler { | 89 class ExitHandler { |
| 90 public: | 90 public: |
| 91 // Invokes exit when appropriate. | 91 // Invokes exit when appropriate. |
| 92 static void ExitWhenPossibleOnUIThread(); | 92 static void ExitWhenPossibleOnUIThread(); |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 ExitHandler(); | 95 ExitHandler(); |
| 96 ~ExitHandler(); | 96 ~ExitHandler(); |
| 97 | 97 |
| 98 // Called when a session restore has finished. | 98 // Called when a session restore has finished. |
| 99 void OnSessionRestoreDone(); | 99 void OnSessionRestoreDone(int num_tabs_restored); |
| 100 | 100 |
| 101 // Does the appropriate call to Exit. | 101 // Does the appropriate call to Exit. |
| 102 static void Exit(); | 102 static void Exit(); |
| 103 | 103 |
| 104 // Points to the on-session-restored callback that was registered with | 104 // Points to the on-session-restored callback that was registered with |
| 105 // SessionRestore's callback list. When objects of this class are destroyed, | 105 // SessionRestore's callback list. When objects of this class are destroyed, |
| 106 // the subscription object's destructor will automatically unregister the | 106 // the subscription object's destructor will automatically unregister the |
| 107 // callback in SessionRestore, so that the callback list does not contain any | 107 // callback in SessionRestore, so that the callback list does not contain any |
| 108 // obsolete callbacks. | 108 // obsolete callbacks. |
| 109 SessionRestore::CallbackSubscription | 109 SessionRestore::CallbackSubscription |
| (...skipping 16 matching lines...) Expand all Loading... |
| 126 ExitHandler::ExitHandler() { | 126 ExitHandler::ExitHandler() { |
| 127 on_session_restored_callback_subscription_ = | 127 on_session_restored_callback_subscription_ = |
| 128 SessionRestore::RegisterOnSessionRestoredCallback( | 128 SessionRestore::RegisterOnSessionRestoredCallback( |
| 129 base::Bind(&ExitHandler::OnSessionRestoreDone, | 129 base::Bind(&ExitHandler::OnSessionRestoreDone, |
| 130 base::Unretained(this))); | 130 base::Unretained(this))); |
| 131 } | 131 } |
| 132 | 132 |
| 133 ExitHandler::~ExitHandler() { | 133 ExitHandler::~ExitHandler() { |
| 134 } | 134 } |
| 135 | 135 |
| 136 void ExitHandler::OnSessionRestoreDone() { | 136 void ExitHandler::OnSessionRestoreDone(int /* num_tabs */) { |
| 137 if (!SessionRestore::IsRestoringSynchronously()) { | 137 if (!SessionRestore::IsRestoringSynchronously()) { |
| 138 // At this point the message loop may not be running (meaning we haven't | 138 // At this point the message loop may not be running (meaning we haven't |
| 139 // gotten through browser startup, but are close). Post the task to at which | 139 // gotten through browser startup, but are close). Post the task to at which |
| 140 // point the message loop is running. | 140 // point the message loop is running. |
| 141 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 141 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 142 base::Bind(&ExitHandler::Exit)); | 142 base::Bind(&ExitHandler::Exit)); |
| 143 delete this; | 143 delete this; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 // Not called on Mac because we load the locale files differently. | 316 // Not called on Mac because we load the locale files differently. |
| 317 NOTREACHED(); | 317 NOTREACHED(); |
| 318 #elif defined(USE_AURA) | 318 #elif defined(USE_AURA) |
| 319 // TODO(port): We may want a views based message dialog here eventually, but | 319 // TODO(port): We may want a views based message dialog here eventually, but |
| 320 // for now, crash. | 320 // for now, crash. |
| 321 NOTREACHED(); | 321 NOTREACHED(); |
| 322 #else | 322 #else |
| 323 #error "Need MessageBox implementation." | 323 #error "Need MessageBox implementation." |
| 324 #endif | 324 #endif |
| 325 } | 325 } |
| OLD | NEW |