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

Side by Side Diff: chrome/browser/tab_contents/background_contents.cc

Issue 2866034: Refactor shutdown code to allow win/linux to run after last browser closes. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Uploaded patch that resolves merge issue Created 10 years, 5 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
« no previous file with comments | « chrome/browser/profile_manager.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/tab_contents/background_contents.h" 5 #include "chrome/browser/tab_contents/background_contents.h"
6 6
7 #include "chrome/browser/background_contents_service.h" 7 #include "chrome/browser/background_contents_service.h"
8 #include "chrome/browser/browser.h" 8 #include "chrome/browser/browser.h"
9 #include "chrome/browser/browser_list.h" 9 #include "chrome/browser/browser_list.h"
10 #include "chrome/browser/browsing_instance.h" 10 #include "chrome/browser/browsing_instance.h"
(...skipping 16 matching lines...) Expand all
27 int routing_id) { 27 int routing_id) {
28 Profile* profile = site_instance->browsing_instance()->profile(); 28 Profile* profile = site_instance->browsing_instance()->profile();
29 29
30 // TODO(rafaelw): Implement correct session storage. 30 // TODO(rafaelw): Implement correct session storage.
31 int64 session_storage_namespace_id = profile->GetWebKitContext()-> 31 int64 session_storage_namespace_id = profile->GetWebKitContext()->
32 dom_storage_context()->AllocateSessionStorageNamespaceId(); 32 dom_storage_context()->AllocateSessionStorageNamespaceId();
33 render_view_host_ = new RenderViewHost(site_instance, this, routing_id, 33 render_view_host_ = new RenderViewHost(site_instance, this, routing_id,
34 session_storage_namespace_id); 34 session_storage_namespace_id);
35 render_view_host_->AllowScriptToClose(true); 35 render_view_host_->AllowScriptToClose(true);
36 36
37 // Close ourselves when the application is shutting down.
38 registrar_.Add(this, NotificationType::APP_TERMINATING,
39 NotificationService::AllSources());
40
37 // Register for our parent profile to shutdown, so we can shut ourselves down 41 // Register for our parent profile to shutdown, so we can shut ourselves down
38 // as well. 42 // as well (should only be called for OTR profiles, as we should receive
43 // APP_TERMINATING before non-OTR profiles are destroyed).
39 registrar_.Add(this, NotificationType::PROFILE_DESTROYED, 44 registrar_.Add(this, NotificationType::PROFILE_DESTROYED,
40 Source<Profile>(profile)); 45 Source<Profile>(profile));
41 } 46 }
42 47
43 // Exposed to allow creating mocks. 48 // Exposed to allow creating mocks.
44 BackgroundContents::BackgroundContents() 49 BackgroundContents::BackgroundContents()
45 : render_view_host_(NULL) { 50 : render_view_host_(NULL) {
46 } 51 }
47 52
48 void BackgroundContents::Observe(NotificationType type, 53 void BackgroundContents::Observe(NotificationType type,
49 const NotificationSource& source, 54 const NotificationSource& source,
50 const NotificationDetails& details) { 55 const NotificationDetails& details) {
51 // TODO(rafaelw): Implement pagegroup ref-counting so that non-persistent 56 // TODO(rafaelw): Implement pagegroup ref-counting so that non-persistent
52 // background pages are closed when the last referencing frame is closed. 57 // background pages are closed when the last referencing frame is closed.
53 switch (type.value) { 58 switch (type.value) {
54 case NotificationType::PROFILE_DESTROYED: { 59 case NotificationType::PROFILE_DESTROYED:
60 case NotificationType::APP_TERMINATING: {
55 delete this; 61 delete this;
56 break; 62 break;
57 } 63 }
58 default: 64 default:
59 NOTREACHED() << "Unexpected notification sent."; 65 NOTREACHED() << "Unexpected notification sent.";
60 break; 66 break;
61 } 67 }
62 } 68 }
63 69
64 BackgroundContents::~BackgroundContents() { 70 BackgroundContents::~BackgroundContents() {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return; 195 return;
190 196
191 browser->AddTabContents(contents, disposition, initial_pos, user_gesture); 197 browser->AddTabContents(contents, disposition, initial_pos, user_gesture);
192 } 198 }
193 199
194 void BackgroundContents::ShowCreatedWidget(int route_id, 200 void BackgroundContents::ShowCreatedWidget(int route_id,
195 const gfx::Rect& initial_pos) { 201 const gfx::Rect& initial_pos) {
196 NOTIMPLEMENTED(); 202 NOTIMPLEMENTED();
197 } 203 }
198 204
OLDNEW
« no previous file with comments | « chrome/browser/profile_manager.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698