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

Side by Side Diff: chrome/browser/automation/automation_provider_observers.cc

Issue 7870008: Wait properly for renderer crashes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_provider_observers.h" 5 #include "chrome/browser/automation/automation_provider_observers.h"
6 6
7 #include <deque> 7 #include <deque>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return load_start_time_; 92 return load_start_time_;
93 } 93 }
94 private: 94 private:
95 base::TimeTicks load_start_time_; 95 base::TimeTicks load_start_time_;
96 base::TimeTicks load_stop_time_; 96 base::TimeTicks load_stop_time_;
97 }; 97 };
98 98
99 InitialLoadObserver::InitialLoadObserver(size_t tab_count, 99 InitialLoadObserver::InitialLoadObserver(size_t tab_count,
100 AutomationProvider* automation) 100 AutomationProvider* automation)
101 : automation_(automation->AsWeakPtr()), 101 : automation_(automation->AsWeakPtr()),
102 crashed_tab_count_(0),
102 outstanding_tab_count_(tab_count), 103 outstanding_tab_count_(tab_count),
103 init_time_(base::TimeTicks::Now()) { 104 init_time_(base::TimeTicks::Now()) {
104 if (outstanding_tab_count_ > 0) { 105 if (outstanding_tab_count_ > 0) {
105 registrar_.Add(this, content::NOTIFICATION_LOAD_START, 106 registrar_.Add(this, content::NOTIFICATION_LOAD_START,
106 NotificationService::AllSources()); 107 NotificationService::AllSources());
107 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, 108 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP,
108 NotificationService::AllSources()); 109 NotificationService::AllSources());
110 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
111 NotificationService::AllSources());
109 } 112 }
110 } 113 }
111 114
112 InitialLoadObserver::~InitialLoadObserver() { 115 InitialLoadObserver::~InitialLoadObserver() {
113 } 116 }
114 117
115 void InitialLoadObserver::Observe(int type, 118 void InitialLoadObserver::Observe(int type,
116 const NotificationSource& source, 119 const NotificationSource& source,
117 const NotificationDetails& details) { 120 const NotificationDetails& details) {
118 if (type == content::NOTIFICATION_LOAD_START) { 121 if (type == content::NOTIFICATION_LOAD_START) {
119 if (outstanding_tab_count_ > loading_tabs_.size()) 122 if (outstanding_tab_count_ > loading_tabs_.size())
120 loading_tabs_.insert(TabTimeMap::value_type( 123 loading_tabs_.insert(TabTimeMap::value_type(
121 source.map_key(), 124 source.map_key(),
122 TabTime(base::TimeTicks::Now()))); 125 TabTime(base::TimeTicks::Now())));
123 } else if (type == content::NOTIFICATION_LOAD_STOP) { 126 } else if (type == content::NOTIFICATION_LOAD_STOP) {
124 if (outstanding_tab_count_ > finished_tabs_.size()) { 127 if (outstanding_tab_count_ > finished_tabs_.size()) {
125 TabTimeMap::iterator iter = loading_tabs_.find(source.map_key()); 128 TabTimeMap::iterator iter = loading_tabs_.find(source.map_key());
126 if (iter != loading_tabs_.end()) { 129 if (iter != loading_tabs_.end()) {
127 finished_tabs_.insert(source.map_key()); 130 finished_tabs_.insert(source.map_key());
128 iter->second.set_stop_time(base::TimeTicks::Now()); 131 iter->second.set_stop_time(base::TimeTicks::Now());
129 } 132 }
130 if (outstanding_tab_count_ == finished_tabs_.size()) 133 }
131 ConditionMet(); 134 } else if (type == content::NOTIFICATION_RENDERER_PROCESS_CLOSED) {
135 base::TerminationStatus status =
136 Details<RenderProcessHost::RendererClosedDetails>(details)->status;
137 switch (status) {
138 case base::TERMINATION_STATUS_NORMAL_TERMINATION:
139 break;
140
141 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION:
142 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED:
143 case base::TERMINATION_STATUS_PROCESS_CRASHED:
144 crashed_tab_count_++;
145 break;
146
147 case base::TERMINATION_STATUS_STILL_RUNNING:
148 LOG(ERROR) << "Got RENDERER_PROCESS_CLOSED notification, "
149 << "but the process is still running. We may miss further "
150 << "crash notification, resulting in hangs.";
151 break;
152
153 default:
154 LOG(ERROR) << "Unhandled termination status " << status;
155 NOTREACHED();
156 break;
132 } 157 }
133 } else { 158 } else {
134 NOTREACHED(); 159 NOTREACHED();
135 } 160 }
161
162 if (finished_tabs_.size() + crashed_tab_count_ >= outstanding_tab_count_)
163 ConditionMet();
136 } 164 }
137 165
138 DictionaryValue* InitialLoadObserver::GetTimingInformation() const { 166 DictionaryValue* InitialLoadObserver::GetTimingInformation() const {
139 ListValue* items = new ListValue; 167 ListValue* items = new ListValue;
140 for (TabTimeMap::const_iterator it = loading_tabs_.begin(); 168 for (TabTimeMap::const_iterator it = loading_tabs_.begin();
141 it != loading_tabs_.end(); 169 it != loading_tabs_.end();
142 ++it) { 170 ++it) {
143 DictionaryValue* item = new DictionaryValue; 171 DictionaryValue* item = new DictionaryValue;
144 base::TimeDelta delta_start = it->second.start_time() - init_time_; 172 base::TimeDelta delta_start = it->second.start_time() - init_time_;
145 173
(...skipping 2554 matching lines...) Expand 10 before | Expand all | Expand 10 after
2700 void DragTargetDropAckNotificationObserver::Observe( 2728 void DragTargetDropAckNotificationObserver::Observe(
2701 int type, 2729 int type,
2702 const NotificationSource& source, 2730 const NotificationSource& source,
2703 const NotificationDetails& details) { 2731 const NotificationDetails& details) {
2704 if (automation_) { 2732 if (automation_) {
2705 AutomationJSONReply(automation_, 2733 AutomationJSONReply(automation_,
2706 reply_message_.release()).SendSuccess(NULL); 2734 reply_message_.release()).SendSuccess(NULL);
2707 } 2735 }
2708 delete this; 2736 delete this;
2709 } 2737 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698