OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/extension_host.h" | 5 #include "extensions/browser/extension_host.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageActiveTime2", | 156 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageActiveTime2", |
157 load_start_->Elapsed()); | 157 load_start_->Elapsed()); |
158 } | 158 } |
159 content::NotificationService::current()->Notify( | 159 content::NotificationService::current()->Notify( |
160 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 160 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
161 content::Source<BrowserContext>(browser_context_), | 161 content::Source<BrowserContext>(browser_context_), |
162 content::Details<ExtensionHost>(this)); | 162 content::Details<ExtensionHost>(this)); |
163 FOR_EACH_OBSERVER(ExtensionHostObserver, observer_list_, | 163 FOR_EACH_OBSERVER(ExtensionHostObserver, observer_list_, |
164 OnExtensionHostDestroyed(this)); | 164 OnExtensionHostDestroyed(this)); |
165 ProcessCreationQueue::GetInstance()->Remove(this); | 165 ProcessCreationQueue::GetInstance()->Remove(this); |
166 // Immediately stop observing |host_contents_| because its destruction events | |
167 // (like DidStopLoading, it turns out) can call back into ExtensionHost | |
168 // re-entrantly, when anything declared after |host_contents_| has already | |
169 // been destroyed. | |
170 content::WebContentsObserver::Observe(NULL); | |
Marijn Kruisselbrink
2015/02/17 20:17:44
nullptr? or was this intentional to stay consisten
not at google - send to devlin
2015/02/17 21:17:34
It's never intentional :-) (and I fixed the rest o
| |
166 } | 171 } |
167 | 172 |
168 content::RenderProcessHost* ExtensionHost::render_process_host() const { | 173 content::RenderProcessHost* ExtensionHost::render_process_host() const { |
169 return render_view_host()->GetProcess(); | 174 return render_view_host()->GetProcess(); |
170 } | 175 } |
171 | 176 |
172 RenderViewHost* ExtensionHost::render_view_host() const { | 177 RenderViewHost* ExtensionHost::render_view_host() const { |
173 // TODO(mpcomplete): This can be NULL. How do we handle that? | 178 // TODO(mpcomplete): This can be NULL. How do we handle that? |
174 return render_view_host_; | 179 return render_view_host_; |
175 } | 180 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 305 extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
301 content::Source<BrowserContext>(browser_context_), | 306 content::Source<BrowserContext>(browser_context_), |
302 content::Details<ExtensionHost>(this)); | 307 content::Details<ExtensionHost>(this)); |
303 } | 308 } |
304 | 309 |
305 void ExtensionHost::DidStopLoading(content::RenderViewHost* render_view_host) { | 310 void ExtensionHost::DidStopLoading(content::RenderViewHost* render_view_host) { |
306 bool notify = !did_stop_loading_; | 311 bool notify = !did_stop_loading_; |
307 did_stop_loading_ = true; | 312 did_stop_loading_ = true; |
308 OnDidStopLoading(); | 313 OnDidStopLoading(); |
309 if (notify) { | 314 if (notify) { |
310 // Log metrics. It's tempting to CHECK(load_start_) here, but it's possible | 315 CHECK(load_start_.get()); |
311 // to get a DidStopLoading even if we never started loading, in convoluted | 316 if (extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
312 // notification and observer chains. | 317 if (extension_ && BackgroundInfo::HasLazyBackgroundPage(extension_)) { |
313 if (load_start_.get()) { | 318 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.EventPageLoadTime2", |
314 if (extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 319 load_start_->Elapsed()); |
315 if (extension_ && BackgroundInfo::HasLazyBackgroundPage(extension_)) { | 320 } else { |
316 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.EventPageLoadTime2", | 321 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.BackgroundPageLoadTime2", |
317 load_start_->Elapsed()); | |
318 } else { | |
319 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.BackgroundPageLoadTime2", | |
320 load_start_->Elapsed()); | |
321 } | |
322 } else if (extension_host_type_ == VIEW_TYPE_EXTENSION_POPUP) { | |
323 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.PopupLoadTime2", | |
324 load_start_->Elapsed()); | 322 load_start_->Elapsed()); |
325 } | 323 } |
324 } else if (extension_host_type_ == VIEW_TYPE_EXTENSION_POPUP) { | |
325 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.PopupLoadTime2", | |
326 load_start_->Elapsed()); | |
326 } | 327 } |
327 | |
328 // Send the notification last, because it might result in this being | 328 // Send the notification last, because it might result in this being |
329 // deleted. | 329 // deleted. |
330 content::NotificationService::current()->Notify( | 330 content::NotificationService::current()->Notify( |
331 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 331 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
332 content::Source<BrowserContext>(browser_context_), | 332 content::Source<BrowserContext>(browser_context_), |
333 content::Details<ExtensionHost>(this)); | 333 content::Details<ExtensionHost>(this)); |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 void ExtensionHost::OnDidStopLoading() { | 337 void ExtensionHost::OnDidStopLoading() { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 return delegate_->CheckMediaAccessPermission( | 484 return delegate_->CheckMediaAccessPermission( |
485 web_contents, security_origin, type, extension()); | 485 web_contents, security_origin, type, extension()); |
486 } | 486 } |
487 | 487 |
488 bool ExtensionHost::IsNeverVisible(content::WebContents* web_contents) { | 488 bool ExtensionHost::IsNeverVisible(content::WebContents* web_contents) { |
489 ViewType view_type = extensions::GetViewType(web_contents); | 489 ViewType view_type = extensions::GetViewType(web_contents); |
490 return view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE; | 490 return view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE; |
491 } | 491 } |
492 | 492 |
493 } // namespace extensions | 493 } // namespace extensions |
OLD | NEW |