1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__
6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__
8 #include "base/memory/ref_counted.h"
9 #include "printing/printing_context.h"
13 class SequencedTaskRunner
;
16 namespace tracked_objects
{
25 class PrintJobWorkerOwner
26 : public base::RefCountedThreadSafe
<PrintJobWorkerOwner
> {
28 PrintJobWorkerOwner();
30 // Finishes the initialization began by PrintJobWorker::GetSettings().
31 // Creates a new PrintedDocument if necessary. Solely meant to be called by
33 virtual void GetSettingsDone(const PrintSettings
& new_settings
,
34 PrintingContext::Result result
) = 0;
36 // Detach the PrintJobWorker associated to this object.
37 virtual PrintJobWorker
* DetachWorker(PrintJobWorkerOwner
* new_owner
) = 0;
39 // Access the current settings.
40 virtual const PrintSettings
& settings() const = 0;
42 // Cookie uniquely identifying the PrintedDocument and/or loaded settings.
43 virtual int cookie() const = 0;
45 // Returns true if the current thread is a thread on which a task
46 // may be run, and false if no task will be run on the current
48 bool RunsTasksOnCurrentThread() const;
50 // Posts the given task to be run.
51 bool PostTask(const tracked_objects::Location
& from_here
,
52 const base::Closure
& task
);
55 friend class base::RefCountedThreadSafe
<PrintJobWorkerOwner
>;
57 virtual ~PrintJobWorkerOwner();
59 // Task runner reference. Used to send notifications in the right
61 scoped_refptr
<base::SequencedTaskRunner
> task_runner_
;
64 } // namespace printing
66 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__