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/instant/instant_unload_handler.h" | 5 #include "chrome/browser/instant/instant_unload_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/ui/browser_navigator.h" | 10 #include "chrome/browser/ui/browser_navigator.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 | 44 |
45 private: | 45 private: |
46 InstantUnloadHandler* const handler_; | 46 InstantUnloadHandler* const handler_; |
47 scoped_ptr<TabContents> tab_contents_; | 47 scoped_ptr<TabContents> tab_contents_; |
48 | 48 |
49 // The index |tab_contents_| was originally at. If we add the tab back we add | 49 // The index |tab_contents_| was originally at. If we add the tab back we add |
50 // it at this index. | 50 // it at this index. |
51 const int index_; | 51 const int index_; |
52 | 52 |
53 DISALLOW_IMPLICIT_CONSTRUCTORS(WebContentsDelegateImpl); | 53 DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateImpl); |
54 }; | 54 }; |
55 | 55 |
56 InstantUnloadHandler::InstantUnloadHandler(Browser* browser) | 56 InstantUnloadHandler::InstantUnloadHandler(Browser* browser) |
57 : browser_(browser) { | 57 : browser_(browser) { |
58 } | 58 } |
59 | 59 |
60 InstantUnloadHandler::~InstantUnloadHandler() { | 60 InstantUnloadHandler::~InstantUnloadHandler() { |
61 } | 61 } |
62 | 62 |
63 void InstantUnloadHandler::RunUnloadListenersOrDestroy(TabContents* tab, | 63 void InstantUnloadHandler::RunUnloadListenersOrDestroy(TabContents* tab, |
(...skipping 30 matching lines...) Expand all Loading... |
94 void InstantUnloadHandler::Destroy(WebContentsDelegateImpl* delegate) { | 94 void InstantUnloadHandler::Destroy(WebContentsDelegateImpl* delegate) { |
95 ScopedVector<WebContentsDelegateImpl>::iterator i = | 95 ScopedVector<WebContentsDelegateImpl>::iterator i = |
96 std::find(delegates_.begin(), delegates_.end(), delegate); | 96 std::find(delegates_.begin(), delegates_.end(), delegate); |
97 DCHECK(i != delegates_.end()); | 97 DCHECK(i != delegates_.end()); |
98 | 98 |
99 // The delegate's method is a caller on the stack, so schedule the deletion | 99 // The delegate's method is a caller on the stack, so schedule the deletion |
100 // for later. | 100 // for later. |
101 delegates_.weak_erase(i); | 101 delegates_.weak_erase(i); |
102 MessageLoop::current()->DeleteSoon(FROM_HERE, delegate); | 102 MessageLoop::current()->DeleteSoon(FROM_HERE, delegate); |
103 } | 103 } |
OLD | NEW |