Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / printing / print_job_worker_owner.h
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.
4
5 #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__
6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__
7
8 #include "base/memory/ref_counted.h"
9 #include "printing/printing_context.h"
10
11 namespace base {
12 class MessageLoop;
13 class SequencedTaskRunner;
14 }
15
16 namespace tracked_objects {
17 class Location;
18 }
19
20 namespace printing {
21
22 class PrintJobWorker;
23 class PrintSettings;
24
25 class PrintJobWorkerOwner
26     : public base::RefCountedThreadSafe<PrintJobWorkerOwner> {
27  public:
28   PrintJobWorkerOwner();
29
30   // Finishes the initialization began by PrintJobWorker::GetSettings().
31   // Creates a new PrintedDocument if necessary. Solely meant to be called by
32   // PrintJobWorker.
33   virtual void GetSettingsDone(const PrintSettings& new_settings,
34                                PrintingContext::Result result) = 0;
35
36   // Detach the PrintJobWorker associated to this object.
37   virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) = 0;
38
39   // Access the current settings.
40   virtual const PrintSettings& settings() const = 0;
41
42   // Cookie uniquely identifying the PrintedDocument and/or loaded settings.
43   virtual int cookie() const = 0;
44
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
47   // thread.
48   bool RunsTasksOnCurrentThread() const;
49
50   // Posts the given task to be run.
51   bool PostTask(const tracked_objects::Location& from_here,
52                 const base::Closure& task);
53
54  protected:
55   friend class base::RefCountedThreadSafe<PrintJobWorkerOwner>;
56
57   virtual ~PrintJobWorkerOwner();
58
59   // Task runner reference. Used to send notifications in the right
60   // thread.
61   scoped_refptr<base::SequencedTaskRunner> task_runner_;
62 };
63
64 }  // namespace printing
65
66 #endif  // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__