| 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/background/background_contents.h" | 5 #include "chrome/browser/background/background_contents.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
| 10 #include "chrome/browser/background/background_contents_service.h" | 10 #include "chrome/browser/background/background_contents_service.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 // Unregister for any notifications before notifying observers that we are | 93 // Unregister for any notifications before notifying observers that we are |
| 94 // going away - this prevents any re-entrancy due to chained notifications | 94 // going away - this prevents any re-entrancy due to chained notifications |
| 95 // (http://crbug.com/237781). | 95 // (http://crbug.com/237781). |
| 96 registrar_.RemoveAll(); | 96 registrar_.RemoveAll(); |
| 97 | 97 |
| 98 content::NotificationService::current()->Notify( | 98 content::NotificationService::current()->Notify( |
| 99 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, | 99 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, |
| 100 content::Source<Profile>(profile_), | 100 content::Source<Profile>(profile_), |
| 101 content::Details<BackgroundContents>(this)); | 101 content::Details<BackgroundContents>(this)); |
| 102 FOR_EACH_OBSERVER(extensions::DeferredStartRenderHostObserver, | 102 for (auto& observer : deferred_start_render_host_observer_list_) |
| 103 deferred_start_render_host_observer_list_, | 103 observer.OnDeferredStartRenderHostDestroyed(this); |
| 104 OnDeferredStartRenderHostDestroyed(this)); | |
| 105 | 104 |
| 106 extension_host_delegate_->GetExtensionHostQueue()->Remove(this); | 105 extension_host_delegate_->GetExtensionHostQueue()->Remove(this); |
| 107 } | 106 } |
| 108 | 107 |
| 109 const GURL& BackgroundContents::GetURL() const { | 108 const GURL& BackgroundContents::GetURL() const { |
| 110 return web_contents_.get() ? web_contents_->GetURL() : GURL::EmptyGURL(); | 109 return web_contents_.get() ? web_contents_->GetURL() : GURL::EmptyGURL(); |
| 111 } | 110 } |
| 112 | 111 |
| 113 void BackgroundContents::CreateRenderViewSoon(const GURL& url) { | 112 void BackgroundContents::CreateRenderViewSoon(const GURL& url) { |
| 114 initial_url_ = url; | 113 initial_url_ = url; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // Our RenderView went away, so we should go away also, so killing the process | 166 // Our RenderView went away, so we should go away also, so killing the process |
| 168 // via the TaskManager doesn't permanently leave a BackgroundContents hanging | 167 // via the TaskManager doesn't permanently leave a BackgroundContents hanging |
| 169 // around the system, blocking future instances from being created | 168 // around the system, blocking future instances from being created |
| 170 // <http://crbug.com/65189>. | 169 // <http://crbug.com/65189>. |
| 171 delete this; | 170 delete this; |
| 172 } | 171 } |
| 173 | 172 |
| 174 void BackgroundContents::DidStartLoading() { | 173 void BackgroundContents::DidStartLoading() { |
| 175 // BackgroundContents only loads once, so this can only be the first time it | 174 // BackgroundContents only loads once, so this can only be the first time it |
| 176 // has started loading. | 175 // has started loading. |
| 177 FOR_EACH_OBSERVER(extensions::DeferredStartRenderHostObserver, | 176 for (auto& observer : deferred_start_render_host_observer_list_) |
| 178 deferred_start_render_host_observer_list_, | 177 observer.OnDeferredStartRenderHostDidStartFirstLoad(this); |
| 179 OnDeferredStartRenderHostDidStartFirstLoad(this)); | |
| 180 } | 178 } |
| 181 | 179 |
| 182 void BackgroundContents::DidStopLoading() { | 180 void BackgroundContents::DidStopLoading() { |
| 183 // BackgroundContents only loads once, so this can only be the first time | 181 // BackgroundContents only loads once, so this can only be the first time |
| 184 // it has stopped loading. | 182 // it has stopped loading. |
| 185 FOR_EACH_OBSERVER(extensions::DeferredStartRenderHostObserver, | 183 for (auto& observer : deferred_start_render_host_observer_list_) |
| 186 deferred_start_render_host_observer_list_, | 184 observer.OnDeferredStartRenderHostDidStopFirstLoad(this); |
| 187 OnDeferredStartRenderHostDidStopFirstLoad(this)); | |
| 188 } | 185 } |
| 189 | 186 |
| 190 void BackgroundContents::Observe(int type, | 187 void BackgroundContents::Observe(int type, |
| 191 const content::NotificationSource& source, | 188 const content::NotificationSource& source, |
| 192 const content::NotificationDetails& details) { | 189 const content::NotificationDetails& details) { |
| 193 // TODO(rafaelw): Implement pagegroup ref-counting so that non-persistent | 190 // TODO(rafaelw): Implement pagegroup ref-counting so that non-persistent |
| 194 // background pages are closed when the last referencing frame is closed. | 191 // background pages are closed when the last referencing frame is closed. |
| 195 switch (type) { | 192 switch (type) { |
| 196 case chrome::NOTIFICATION_PROFILE_DESTROYED: | 193 case chrome::NOTIFICATION_PROFILE_DESTROYED: |
| 197 case chrome::NOTIFICATION_APP_TERMINATING: { | 194 case chrome::NOTIFICATION_APP_TERMINATING: { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 216 | 213 |
| 217 void BackgroundContents::AddDeferredStartRenderHostObserver( | 214 void BackgroundContents::AddDeferredStartRenderHostObserver( |
| 218 extensions::DeferredStartRenderHostObserver* observer) { | 215 extensions::DeferredStartRenderHostObserver* observer) { |
| 219 deferred_start_render_host_observer_list_.AddObserver(observer); | 216 deferred_start_render_host_observer_list_.AddObserver(observer); |
| 220 } | 217 } |
| 221 | 218 |
| 222 void BackgroundContents::RemoveDeferredStartRenderHostObserver( | 219 void BackgroundContents::RemoveDeferredStartRenderHostObserver( |
| 223 extensions::DeferredStartRenderHostObserver* observer) { | 220 extensions::DeferredStartRenderHostObserver* observer) { |
| 224 deferred_start_render_host_observer_list_.RemoveObserver(observer); | 221 deferred_start_render_host_observer_list_.RemoveObserver(observer); |
| 225 } | 222 } |
| OLD | NEW |