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/automation/automation_tab_helper.h" | 5 #include "chrome/browser/automation/automation_tab_helper.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "chrome/common/automation_messages.h" | 9 #include "chrome/common/automation_messages.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 #if !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) | 58 #if !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) |
59 void AutomationTabHelper::HeapProfilerDump(const std::string& reason) { | 59 void AutomationTabHelper::HeapProfilerDump(const std::string& reason) { |
60 Send(new AutomationMsg_HeapProfilerDump(routing_id(), reason)); | 60 Send(new AutomationMsg_HeapProfilerDump(routing_id(), reason)); |
61 } | 61 } |
62 #endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) | 62 #endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) |
63 | 63 |
64 bool AutomationTabHelper::has_pending_loads() const { | 64 bool AutomationTabHelper::has_pending_loads() const { |
65 return is_loading_ || !pending_client_redirects_.empty(); | 65 return is_loading_ || !pending_client_redirects_.empty(); |
66 } | 66 } |
67 | 67 |
68 void AutomationTabHelper::DidStartLoading() { | 68 void AutomationTabHelper::DidStartLoading( |
| 69 content::RenderViewHost* render_view_host) { |
69 if (is_loading_) { | 70 if (is_loading_) { |
70 // DidStartLoading is often called twice. Once when the renderer sends a | 71 // DidStartLoading is often called twice. Once when the renderer sends a |
71 // load start message, and once when the browser calls it directly as a | 72 // load start message, and once when the browser calls it directly as a |
72 // result of some user-initiated navigation. | 73 // result of some user-initiated navigation. |
73 VLOG(1) << "Received DidStartLoading while loading already started."; | 74 VLOG(1) << "Received DidStartLoading while loading already started."; |
74 return; | 75 return; |
75 } | 76 } |
76 bool had_pending_loads = has_pending_loads(); | 77 bool had_pending_loads = has_pending_loads(); |
77 is_loading_ = true; | 78 is_loading_ = true; |
78 if (!had_pending_loads) { | 79 if (!had_pending_loads) { |
79 FOR_EACH_OBSERVER(TabEventObserver, observers_, | 80 FOR_EACH_OBSERVER(TabEventObserver, observers_, |
80 OnFirstPendingLoad(web_contents())); | 81 OnFirstPendingLoad(web_contents())); |
81 } | 82 } |
82 } | 83 } |
83 | 84 |
84 void AutomationTabHelper::DidStopLoading() { | 85 void AutomationTabHelper::DidStopLoading( |
| 86 content::RenderViewHost* render_view_host) { |
85 if (!is_loading_) { | 87 if (!is_loading_) { |
86 LOG(WARNING) << "Received DidStopLoading while loading already stopped."; | 88 LOG(WARNING) << "Received DidStopLoading while loading already stopped."; |
87 return; | 89 return; |
88 } | 90 } |
89 is_loading_ = false; | 91 is_loading_ = false; |
90 if (!has_pending_loads()) { | 92 if (!has_pending_loads()) { |
91 FOR_EACH_OBSERVER(TabEventObserver, observers_, | 93 FOR_EACH_OBSERVER(TabEventObserver, observers_, |
92 OnNoMorePendingLoads(web_contents())); | 94 OnNoMorePendingLoads(web_contents())); |
93 } | 95 } |
94 } | 96 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // It is possible that we did not track the redirect becasue it had a non-zero | 163 // It is possible that we did not track the redirect becasue it had a non-zero |
162 // delay. See the comment in |OnWillPerformClientRedirect|. | 164 // delay. See the comment in |OnWillPerformClientRedirect|. |
163 if (iter != pending_client_redirects_.end()) { | 165 if (iter != pending_client_redirects_.end()) { |
164 pending_client_redirects_.erase(iter); | 166 pending_client_redirects_.erase(iter); |
165 if (!has_pending_loads()) { | 167 if (!has_pending_loads()) { |
166 FOR_EACH_OBSERVER(TabEventObserver, observers_, | 168 FOR_EACH_OBSERVER(TabEventObserver, observers_, |
167 OnNoMorePendingLoads(web_contents())); | 169 OnNoMorePendingLoads(web_contents())); |
168 } | 170 } |
169 } | 171 } |
170 } | 172 } |
OLD | NEW |