summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-13 17:32:56 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-13 17:32:56 +0000
commit65132db90c1de8183e4ef0bb8add33167855812a (patch)
tree21f8b2050040f2bfec1851a852923633b8dd1be8
parent328105ba0bc7d658cf59debb08139fcc66ed1a85 (diff)
downloadchromium_src-65132db90c1de8183e4ef0bb8add33167855812a.zip
chromium_src-65132db90c1de8183e4ef0bb8add33167855812a.tar.gz
chromium_src-65132db90c1de8183e4ef0bb8add33167855812a.tar.bz2
Merge 88582 - Attempt at fixing crash. It looks like the printing code can delete
the TabContents, not the TabContentsWrapper, which leaves the TabContentsWrapper (and its associated helper classes) with references to a deleted TabContents. BUG=85455 TEST=none R=thestig@chromium.org Review URL: http://codereview.chromium.org/7104074 TBR=sky@chromium.org Review URL: http://codereview.chromium.org/7046111 git-svn-id: svn://svn.chromium.org/chrome/branches/782/src@88840 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/printing/background_printing_manager.cc18
-rw-r--r--chrome/browser/printing/print_view_manager.cc10
-rw-r--r--chrome/browser/printing/print_view_manager.h7
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents_wrapper.cc2
-rw-r--r--content/common/notification_type.h2
5 files changed, 23 insertions, 16 deletions
diff --git a/chrome/browser/printing/background_printing_manager.cc b/chrome/browser/printing/background_printing_manager.cc
index 997fab7..e36e811 100644
--- a/chrome/browser/printing/background_printing_manager.cc
+++ b/chrome/browser/printing/background_printing_manager.cc
@@ -36,7 +36,7 @@ void BackgroundPrintingManager::OwnTabContents(TabContentsWrapper* contents) {
printing_contents_.insert(contents);
registrar_.Add(this, NotificationType::PRINT_JOB_RELEASED,
- Source<TabContents>(contents->tab_contents()));
+ Source<TabContentsWrapper>(contents));
registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED,
Source<TabContents>(contents->tab_contents()));
@@ -65,18 +65,20 @@ void BackgroundPrintingManager::Observe(NotificationType type,
case NotificationType::PRINT_JOB_RELEASED: {
// This might be happening in the middle of a RenderViewGone() loop.
// Deleting |contents| later so the RenderViewGone() loop can finish.
- MessageLoop::current()->DeleteSoon(FROM_HERE,
- Source<TabContents>(source).ptr());
+ MessageLoop::current()->DeleteSoon(
+ FROM_HERE,
+ Source<TabContentsWrapper>(source).ptr());
break;
}
case NotificationType::TAB_CONTENTS_DESTROYED: {
- TabContents* contents = Source<TabContents>(source).ptr();
+ TabContentsWrapper* tab =
+ TabContentsWrapper::GetCurrentWrapperForContents(
+ Source<TabContents>(source).ptr());
registrar_.Remove(this, NotificationType::PRINT_JOB_RELEASED,
- Source<TabContents>(contents));
+ Source<TabContentsWrapper>(tab));
registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED,
- Source<TabContents>(contents));
- printing_contents_.erase(
- TabContentsWrapper::GetCurrentWrapperForContents(contents));
+ Source<TabContents>(tab->tab_contents()));
+ printing_contents_.erase(tab);
break;
}
default: {
diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc
index d460c46..b284d1d 100644
--- a/chrome/browser/printing/print_view_manager.cc
+++ b/chrome/browser/printing/print_view_manager.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/print_preview_tab_controller.h"
#include "chrome/browser/printing/printer_query.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/webui/print_preview_ui.h"
#include "chrome/common/print_messages.h"
#include "content/browser/renderer_host/render_view_host.h"
@@ -40,8 +41,9 @@ string16 GenerateRenderSourceName(TabContents* tab_contents) {
namespace printing {
-PrintViewManager::PrintViewManager(TabContents* tab_contents)
- : TabContentsObserver(tab_contents),
+PrintViewManager::PrintViewManager(TabContentsWrapper* tab)
+ : TabContentsObserver(tab->tab_contents()),
+ tab_(tab),
number_pages_(0),
printing_succeeded_(false),
inside_inner_message_loop_(false),
@@ -226,7 +228,7 @@ void PrintViewManager::OnNotifyPrintJobEvent(
NotificationService::current()->Notify(
NotificationType::PRINT_JOB_RELEASED,
- Source<TabContents>(tab_contents()),
+ Source<TabContentsWrapper>(tab_),
NotificationService::NoDetails());
break;
}
@@ -256,7 +258,7 @@ void PrintViewManager::OnNotifyPrintJobEvent(
NotificationService::current()->Notify(
NotificationType::PRINT_JOB_RELEASED,
- Source<TabContents>(tab_contents()),
+ Source<TabContentsWrapper>(tab_),
NotificationService::NoDetails());
break;
}
diff --git a/chrome/browser/printing/print_view_manager.h b/chrome/browser/printing/print_view_manager.h
index 3cad0f8..f26061c 100644
--- a/chrome/browser/printing/print_view_manager.h
+++ b/chrome/browser/printing/print_view_manager.h
@@ -14,7 +14,7 @@
#include "printing/printed_pages_source.h"
class RenderViewHost;
-class TabContents;
+class TabContentsWrapper;
struct PrintHostMsg_DidPrintPage_Params;
namespace printing {
@@ -29,7 +29,7 @@ class PrintViewManager : public NotificationObserver,
public PrintedPagesSource,
public TabContentsObserver {
public:
- explicit PrintViewManager(TabContents* tab_contents);
+ explicit PrintViewManager(TabContentsWrapper* tab);
virtual ~PrintViewManager();
// Override the title for this PrintViewManager's PrintJobs using the title
@@ -119,6 +119,9 @@ class PrintViewManager : public NotificationObserver,
// print_job_ is initialized.
bool OpportunisticallyCreatePrintJob(int cookie);
+ // TabContentsWrapper we're associated with.
+ TabContentsWrapper* tab_;
+
NotificationRegistrar registrar_;
// Manages the low-level talk to the printer.
diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
index 0db8125..a923e4a 100644
--- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
+++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
@@ -125,7 +125,7 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents)
ssl_helper_.reset(new TabContentsSSLHelper(this));
content_settings_.reset(new TabSpecificContentSettings(contents));
translate_tab_helper_.reset(new TranslateTabHelper(contents));
- print_view_manager_.reset(new printing::PrintViewManager(contents));
+ print_view_manager_.reset(new printing::PrintViewManager(this));
// Create the per-tab observers.
external_protocol_observer_.reset(new ExternalProtocolObserver(contents));
diff --git a/content/common/notification_type.h b/content/common/notification_type.h
index b5b0b3d..3c3b84b 100644
--- a/content/common/notification_type.h
+++ b/content/common/notification_type.h
@@ -792,7 +792,7 @@ class NotificationType {
PRINT_JOB_EVENT,
// Sent when a PrintJob has been released.
- // Source is the TabContents that holds the print job.
+ // Source is the TabContentsWrapper that holds the print job.
PRINT_JOB_RELEASED,
// Shutdown ----------------------------------------------------------------