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

Unified Diff: chrome/browser/ui/unload_detached_handler.h

Issue 11016023: Quickly close tabs/window with long-running unload handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add UnloadController class comment. Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/unload_detached_handler.h
diff --git a/chrome/browser/ui/unload_detached_handler.h b/chrome/browser/ui/unload_detached_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..91cd9150dcd9b597a7cd5bc533d38f6930c96d25
--- /dev/null
+++ b/chrome/browser/ui/unload_detached_handler.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_UNLOAD_DETACHED_HANDLER_H_
+#define CHROME_BROWSER_UI_UNLOAD_DETACHED_HANDLER_H_
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/memory/scoped_vector.h"
+
+class TabStripModel;
+
+namespace content {
+class WebContents;
+}
+
+namespace chrome {
+
+class UnloadController;
+
+typedef base::Callback<void(void)> TabsClosedCallback;
+
+// UnloadDetachedHandler is used to close tabs quickly, http://crbug.com/142458.
+// - Allows unload handlers to run in the background.
+// - Comes into play after the beforeunload handlers (if any) have run.
+// - Does not close the tabs; it holds tabs while they are closed.
+//
+// TODO(slamm): Support closes that destroy the browser: last tab close, window.
+// http://crbug.com/156896
+// TODO(slamm): Hide unload time from the user for cross-process navigations.
+// http://crbug.com/156958
+class UnloadDetachedHandler {
+ public:
+ explicit UnloadDetachedHandler(const TabsClosedCallback& callback);
+ ~UnloadDetachedHandler();
+
+ // Returns true if is succeeds.
+ bool DetachWebContents(TabStripModel* tab_strip_model,
+ content::WebContents* web_contents);
+ bool HasTabs();
Ben Goodger (Google) 2012/10/29 22:12:43 this kind of method can be const.
slamm 2012/10/31 18:03:59 Done.
+
+ private:
+ class WebContentsDelegateImpl;
+
+ // Clean-up when the tab finishes closing.
+ void Destroy(WebContentsDelegateImpl* delegate);
+
+ const TabsClosedCallback tabs_closed_callback_;
+
+ ScopedVector<WebContentsDelegateImpl> delegates_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(UnloadDetachedHandler);
+};
+
+} // namespace chrome
+
+#endif // CHROME_BROWSER_UI_UNLOAD_DETACHED_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698