| 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 "base/profiler/scoped_tracker.h" | 7 #include "base/profiler/scoped_tracker.h" |
| 8 #include "chrome/browser/background/background_contents_service.h" | 8 #include "chrome/browser/background/background_contents_service.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 10 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 // Our RenderView went away, so we should go away also, so killing the process | 158 // Our RenderView went away, so we should go away also, so killing the process |
| 159 // via the TaskManager doesn't permanently leave a BackgroundContents hanging | 159 // via the TaskManager doesn't permanently leave a BackgroundContents hanging |
| 160 // around the system, blocking future instances from being created | 160 // around the system, blocking future instances from being created |
| 161 // <http://crbug.com/65189>. | 161 // <http://crbug.com/65189>. |
| 162 delete this; | 162 delete this; |
| 163 } | 163 } |
| 164 | 164 |
| 165 void BackgroundContents::DidStartLoading( | 165 void BackgroundContents::DidStartLoading( |
| 166 content::RenderViewHost* render_view_host) { | 166 content::RenderViewHost* render_view_host) { |
| 167 // BackgroundContents only loads once, so this can only be the first time it |
| 168 // has started loading. |
| 167 FOR_EACH_OBSERVER(extensions::DeferredStartRenderHostObserver, | 169 FOR_EACH_OBSERVER(extensions::DeferredStartRenderHostObserver, |
| 168 deferred_start_render_host_observer_list_, | 170 deferred_start_render_host_observer_list_, |
| 169 OnDeferredStartRenderHostDidStartLoading(this)); | 171 OnDeferredStartRenderHostDidStartFirstLoad(this)); |
| 170 } | 172 } |
| 171 | 173 |
| 172 void BackgroundContents::DidStopLoading( | 174 void BackgroundContents::DidStopLoading( |
| 173 content::RenderViewHost* render_view_host) { | 175 content::RenderViewHost* render_view_host) { |
| 176 // BackgroundContents only loads once, so this can only be the first time |
| 177 // it has stopped loading. |
| 174 FOR_EACH_OBSERVER(extensions::DeferredStartRenderHostObserver, | 178 FOR_EACH_OBSERVER(extensions::DeferredStartRenderHostObserver, |
| 175 deferred_start_render_host_observer_list_, | 179 deferred_start_render_host_observer_list_, |
| 176 OnDeferredStartRenderHostDidStopLoading(this)); | 180 OnDeferredStartRenderHostDidStopFirstLoad(this)); |
| 177 } | 181 } |
| 178 | 182 |
| 179 void BackgroundContents::Observe(int type, | 183 void BackgroundContents::Observe(int type, |
| 180 const content::NotificationSource& source, | 184 const content::NotificationSource& source, |
| 181 const content::NotificationDetails& details) { | 185 const content::NotificationDetails& details) { |
| 182 // TODO(rafaelw): Implement pagegroup ref-counting so that non-persistent | 186 // TODO(rafaelw): Implement pagegroup ref-counting so that non-persistent |
| 183 // background pages are closed when the last referencing frame is closed. | 187 // background pages are closed when the last referencing frame is closed. |
| 184 switch (type) { | 188 switch (type) { |
| 185 case chrome::NOTIFICATION_PROFILE_DESTROYED: | 189 case chrome::NOTIFICATION_PROFILE_DESTROYED: |
| 186 case chrome::NOTIFICATION_APP_TERMINATING: { | 190 case chrome::NOTIFICATION_APP_TERMINATING: { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 205 | 209 |
| 206 void BackgroundContents::AddDeferredStartRenderHostObserver( | 210 void BackgroundContents::AddDeferredStartRenderHostObserver( |
| 207 extensions::DeferredStartRenderHostObserver* observer) { | 211 extensions::DeferredStartRenderHostObserver* observer) { |
| 208 deferred_start_render_host_observer_list_.AddObserver(observer); | 212 deferred_start_render_host_observer_list_.AddObserver(observer); |
| 209 } | 213 } |
| 210 | 214 |
| 211 void BackgroundContents::RemoveDeferredStartRenderHostObserver( | 215 void BackgroundContents::RemoveDeferredStartRenderHostObserver( |
| 212 extensions::DeferredStartRenderHostObserver* observer) { | 216 extensions::DeferredStartRenderHostObserver* observer) { |
| 213 deferred_start_render_host_observer_list_.RemoveObserver(observer); | 217 deferred_start_render_host_observer_list_.RemoveObserver(observer); |
| 214 } | 218 } |
| OLD | NEW |