Reverting 5971.
Review URL: http://codereview.chromium.org/12637 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5974 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
base
chrome
browser
renderer
test
@ -131,6 +131,9 @@ void Thread::StopSoon() {
|
||||
DCHECK(message_loop_);
|
||||
|
||||
message_loop_->PostTask(FROM_HERE, new ThreadQuitTask());
|
||||
|
||||
// The thread can't receive messages anymore.
|
||||
message_loop_ = NULL;
|
||||
}
|
||||
|
||||
void Thread::ThreadMain() {
|
||||
|
@ -97,8 +97,8 @@ TEST_F(ThreadTest, StopSoon) {
|
||||
EXPECT_TRUE(a.Start());
|
||||
EXPECT_TRUE(a.message_loop());
|
||||
a.StopSoon();
|
||||
EXPECT_FALSE(a.message_loop());
|
||||
a.StopSoon();
|
||||
a.Stop();
|
||||
EXPECT_FALSE(a.message_loop());
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,6 @@ PrintJob::PrintJob(PrintedPagesSource* source)
|
||||
is_job_pending_(false),
|
||||
is_print_dialog_box_shown_(false),
|
||||
is_canceling_(false) {
|
||||
DCHECK(ui_message_loop_);
|
||||
ui_message_loop_->AddDestructionObserver(this);
|
||||
}
|
||||
|
||||
PrintJob::PrintJob()
|
||||
@ -36,18 +34,14 @@ PrintJob::PrintJob()
|
||||
is_job_pending_(false),
|
||||
is_print_dialog_box_shown_(false),
|
||||
is_canceling_(false) {
|
||||
DCHECK(ui_message_loop_);
|
||||
ui_message_loop_->AddDestructionObserver(this);
|
||||
}
|
||||
|
||||
PrintJob::~PrintJob() {
|
||||
ui_message_loop_->RemoveDestructionObserver(this);
|
||||
// The job should be finished (or at least canceled) when it is destroyed.
|
||||
DCHECK(!is_job_pending_);
|
||||
DCHECK(!is_print_dialog_box_shown_);
|
||||
DCHECK(!is_canceling_);
|
||||
if (worker_.get())
|
||||
DCHECK(worker_->message_loop() == NULL);
|
||||
DCHECK(worker_->message_loop() == NULL);
|
||||
DCHECK_EQ(ui_message_loop_, MessageLoop::current());
|
||||
}
|
||||
|
||||
@ -148,10 +142,6 @@ int PrintJob::cookie() const {
|
||||
return document_->cookie();
|
||||
}
|
||||
|
||||
void PrintJob::WillDestroyCurrentMessageLoop() {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
void PrintJob::GetSettings(GetSettingsAskParam ask_user_for_settings,
|
||||
HWND parent_window) {
|
||||
DCHECK_EQ(ui_message_loop_, MessageLoop::current());
|
||||
|
@ -5,7 +5,6 @@
|
||||
#ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_H_
|
||||
#define CHROME_BROWSER_PRINTING_PRINT_JOB_H_
|
||||
|
||||
#include "base/message_loop.h"
|
||||
#include "base/ref_counted.h"
|
||||
#include "chrome/browser/printing/print_job_worker_owner.h"
|
||||
#include "chrome/common/notification_service.h"
|
||||
@ -33,8 +32,7 @@ class PrinterQuery;
|
||||
// runs in the UI thread.
|
||||
class PrintJob : public base::RefCountedThreadSafe<PrintJob>,
|
||||
public NotificationObserver,
|
||||
public PrintJobWorkerOwner,
|
||||
public MessageLoop::DestructionObserver {
|
||||
public PrintJobWorkerOwner {
|
||||
public:
|
||||
// GetSettings() UI parameter.
|
||||
enum GetSettingsAskParam {
|
||||
@ -50,8 +48,6 @@ class PrintJob : public base::RefCountedThreadSafe<PrintJob>,
|
||||
PrintJob();
|
||||
virtual ~PrintJob();
|
||||
|
||||
// Grabs the ownership of the PrintJobWorker from another job, which is
|
||||
// usually a PrinterQuery.
|
||||
void Initialize(PrintJobWorkerOwner* job, PrintedPagesSource* source);
|
||||
|
||||
// NotificationObserver
|
||||
@ -73,9 +69,6 @@ class PrintJob : public base::RefCountedThreadSafe<PrintJob>,
|
||||
virtual const PrintSettings& settings() const { return settings_; }
|
||||
virtual int cookie() const;
|
||||
|
||||
// DestructionObserver
|
||||
virtual void WillDestroyCurrentMessageLoop();
|
||||
|
||||
// Initializes the printing context. This can be done synchronously or not. It
|
||||
// is fine to call this function multiple times to reinitialize the settings.
|
||||
// |parent_window| parameter will be the owner of the print setting dialog
|
||||
|
@ -1,117 +0,0 @@
|
||||
// Copyright (c) 2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/message_loop.h"
|
||||
#include "chrome/browser/printing/print_job.h"
|
||||
#include "chrome/browser/printing/printed_pages_source.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace {
|
||||
|
||||
class TestSource : public printing::PrintedPagesSource {
|
||||
public:
|
||||
virtual void RenderOnePrintedPage(printing::PrintedDocument* document,
|
||||
int page_number) {
|
||||
}
|
||||
virtual std::wstring RenderSourceName() {
|
||||
return L"";
|
||||
}
|
||||
virtual GURL RenderSourceUrl() {
|
||||
return GURL();
|
||||
}
|
||||
};
|
||||
|
||||
class TestPrintJob : public printing::PrintJob {
|
||||
public:
|
||||
TestPrintJob(printing::PrintedPagesSource* source, volatile bool* check)
|
||||
: printing::PrintJob(source), check_(check) {
|
||||
}
|
||||
TestPrintJob(volatile bool* check) : check_(check) {
|
||||
}
|
||||
~TestPrintJob() {
|
||||
*check_ = true;
|
||||
}
|
||||
private:
|
||||
volatile bool* check_;
|
||||
};
|
||||
|
||||
class TestPrintNotifObserv : public NotificationObserver {
|
||||
public:
|
||||
// NotificationObserver
|
||||
virtual void Observe(NotificationType type,
|
||||
const NotificationSource& source,
|
||||
const NotificationDetails& details) {
|
||||
ASSERT_EQ(NOTIFY_PRINT_JOB_EVENT, type);
|
||||
printing::JobEventDetails::Type event_type =
|
||||
Details<printing::JobEventDetails>(details)->type();
|
||||
EXPECT_NE(printing::JobEventDetails::NEW_DOC, event_type);
|
||||
EXPECT_NE(printing::JobEventDetails::NEW_PAGE, event_type);
|
||||
EXPECT_NE(printing::JobEventDetails::PAGE_DONE, event_type);
|
||||
EXPECT_NE(printing::JobEventDetails::DOC_DONE, event_type);
|
||||
EXPECT_NE(printing::JobEventDetails::JOB_DONE, event_type);
|
||||
EXPECT_NE(printing::JobEventDetails::ALL_PAGES_REQUESTED, event_type);
|
||||
if (event_type == printing::JobEventDetails::USER_INIT_DONE ||
|
||||
event_type == printing::JobEventDetails::USER_INIT_CANCELED ||
|
||||
event_type == printing::JobEventDetails::DEFAULT_INIT_DONE ||
|
||||
event_type == printing::JobEventDetails::FAILED) {
|
||||
MessageLoop::current()->Quit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(PrintJobTest, SimplePrint) {
|
||||
// Test the multithreaded nature of PrintJob to make sure we can use it with
|
||||
// known livetime.
|
||||
TestPrintNotifObserv observ;
|
||||
MessageLoop current;
|
||||
NotificationService::current()->AddObserver(
|
||||
&observ, NOTIFY_ALL,
|
||||
NotificationService::AllSources());
|
||||
TestSource source;
|
||||
volatile bool check = false;
|
||||
scoped_refptr<printing::PrintJob> job(new TestPrintJob(&source, &check));
|
||||
job->GetSettings(printing::PrintJob::DEFAULTS, NULL);
|
||||
EXPECT_EQ(MessageLoop::current(), job->message_loop());
|
||||
current.Run();
|
||||
job->Stop();
|
||||
job = NULL;
|
||||
EXPECT_TRUE(check);
|
||||
}
|
||||
|
||||
TEST(PrintJobTest, SimplePrintLateInit) {
|
||||
volatile bool check = false;
|
||||
MessageLoop current;
|
||||
scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check));
|
||||
job = NULL;
|
||||
EXPECT_TRUE(check);
|
||||
/* TODO(maruel): Test these.
|
||||
job->Initialize()
|
||||
job->Observe();
|
||||
job->GetSettingsDone();
|
||||
job->DetachWorker();
|
||||
job->message_loop();
|
||||
job->settings();
|
||||
job->cookie();
|
||||
job->GetSettings(printing::DEFAULTS, printing::ASK_USER, NULL);
|
||||
job->StartPrinting();
|
||||
job->Stop();
|
||||
job->Cancel();
|
||||
job->RequestMissingPages();
|
||||
job->FlushJob(timeout_ms);
|
||||
job->DisconnectSource();
|
||||
job->is_job_pending();
|
||||
job->is_print_dialog_box_shown();
|
||||
job->document();
|
||||
// Private
|
||||
job->UpdatePrintedDocument(NULL);
|
||||
scoped_refptr<printing::JobEventDetails> event_details;
|
||||
job->OnNotifyPrintJobEvent(event_details);
|
||||
job->OnDocumentDone();
|
||||
job->ControlledWorkerShutdown();
|
||||
*/
|
||||
}
|
@ -453,7 +453,6 @@ int RenderView::SwitchFrameToPrintMediaType(const ViewMsg_Print_Params& params,
|
||||
NOTREACHED();
|
||||
pages = 0;
|
||||
} else {
|
||||
DCHECK_GT(printed_document_width_, 0);
|
||||
// Force to recalculate the height, otherwise it reuse the current window
|
||||
// height as the default.
|
||||
float effective_shrink = printed_document_width_ / paper_width;
|
||||
|
@ -175,7 +175,6 @@ if env['PLATFORM'] == 'win32':
|
||||
'$CHROME_DIR/browser/password_form_manager_unittest.cc',
|
||||
'$CHROME_DIR/browser/printing/page_number_unittest.cc',
|
||||
'$CHROME_DIR/browser/printing/page_overlays_unittest.cc',
|
||||
'$CHROME_DIR/browser/printing/print_job_unittest.cc',
|
||||
'$CHROME_DIR/browser/printing/win_printing_context_unittest.cc',
|
||||
'$CHROME_DIR/browser/profile_manager_unittest.cc',
|
||||
'$CHROME_DIR/browser/renderer_security_policy_unittest.cc',
|
||||
|
@ -781,10 +781,6 @@
|
||||
RelativePath="..\..\browser\printing\page_setup_unittest.cc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\browser\printing\print_job_unittest.cc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\browser\printing\printing_test.h"
|
||||
>
|
||||
|
Reference in New Issue
Block a user