Chromium Code Reviews| Index: chrome/browser/printing/print_job_worker.cc |
| diff --git a/chrome/browser/printing/print_job_worker.cc b/chrome/browser/printing/print_job_worker.cc |
| index 2dcd7887343b3bfdc100bbde7300ca41d314b7ae..8cc2e62eb56e9a0262821de3873a703718a3c5cc 100644 |
| --- a/chrome/browser/printing/print_job_worker.cc |
| +++ b/chrome/browser/printing/print_job_worker.cc |
| @@ -13,7 +13,6 @@ |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/chrome_notification_types.h" |
| #include "chrome/browser/printing/print_job.h" |
| -#include "chrome/browser/printing/printing_ui_web_contents_observer.h" |
| #include "chrome/grit/generated_resources.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/notification_service.h" |
| @@ -46,58 +45,35 @@ class PrintingContextDelegate : public PrintingContext::Delegate { |
| virtual std::string GetAppLocale() OVERRIDE; |
| private: |
| - void InitOnUiThread(int render_process_id, int render_view_id); |
| - |
| - scoped_ptr<PrintingUIWebContentsObserver> web_contents_observer_; |
| + int render_process_id_; |
| + int render_view_id_; |
| base::WeakPtrFactory<PrintingContextDelegate> weak_ptr_factory_; |
| }; |
| PrintingContextDelegate::PrintingContextDelegate(int render_process_id, |
| int render_view_id) |
| - : weak_ptr_factory_(this) { |
| - InitOnUiThread(render_process_id, render_view_id); |
| + : weak_ptr_factory_(this), |
| + render_process_id_(render_process_id), |
| + render_view_id_(render_view_id) { |
| } |
| PrintingContextDelegate::~PrintingContextDelegate() { |
| - DCHECK_CURRENTLY_ON(BrowserThread::UI); |
|
Noam Samuel
2014/08/26 21:09:30
Have DCHECK for new thread if it matters?
Vitaly Buka (NO REVIEWS)
2014/08/26 21:12:24
web_contents_observer_ was the reason we wanted de
|
| } |
| gfx::NativeView PrintingContextDelegate::GetParentView() { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| - if (!web_contents_observer_) |
| + content::RenderViewHost* view = |
| + content::RenderViewHost::FromID(render_process_id_, render_view_id_); |
| + if (!view) |
| return NULL; |
| - return web_contents_observer_->GetParentView(); |
| + content::WebContents* wc = content::WebContents::FromRenderViewHost(view); |
| + return wc ? wc->GetNativeView() : NULL; |
| } |
| std::string PrintingContextDelegate::GetAppLocale() { |
| return g_browser_process->GetApplicationLocale(); |
| } |
| -void PrintingContextDelegate::InitOnUiThread(int render_process_id, |
| - int render_view_id) { |
| - if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| - // All data initialized here should be accessed on UI thread. Because object |
| - // is being constructed now, anything that is going to access |
| - // PrintingContextDelegate on UI thread would be scheduled after the tasks |
| - // below. |
| - BrowserThread::PostTask(BrowserThread::UI, |
| - FROM_HERE, |
| - base::Bind(&PrintingContextDelegate::InitOnUiThread, |
| - weak_ptr_factory_.GetWeakPtr(), |
| - render_process_id, |
| - render_view_id)); |
| - return; |
| - } |
| - content::RenderViewHost* view = |
| - content::RenderViewHost::FromID(render_process_id, render_view_id); |
| - if (!view) |
| - return; |
| - content::WebContents* wc = content::WebContents::FromRenderViewHost(view); |
| - if (!wc) |
| - return; |
| - web_contents_observer_.reset(new PrintingUIWebContentsObserver(wc)); |
| -} |
| - |
| void NotificationCallback(PrintJobWorkerOwner* print_job, |
| JobEventDetails::Type detail_type, |
| PrintedDocument* document, |