Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: chrome/browser/printing/cloud_print/job_status_updater.h

Issue 1566047: First cut of Cloud Print Proxy implementation. The code is not enabled for no... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Final review changes Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 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_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
7
8 #include <string>
9
10 #include "base/file_path.h"
11 #include "base/ref_counted.h"
12 #include "base/thread.h"
13 #include "chrome/browser/printing/cloud_print/printer_info.h"
14 #include "chrome/browser/net/url_fetcher.h"
15 #include "net/url_request/url_request_status.h"
16
17 // Periodically monitors the status of a local print job and updates the
18 // cloud print server accordingly. When the job has been completed this
19 // object releases the reference to itself which should cause it to
20 // self-destruct.
21 class JobStatusUpdater : public base::RefCountedThreadSafe<JobStatusUpdater>,
22 public URLFetcher::Delegate {
23 public:
24 class Delegate {
25 public:
26 virtual bool OnJobCompleted(JobStatusUpdater* updater) = 0;
27 };
28
29 JobStatusUpdater(const std::string& printer_name,
30 const std::string& job_id,
31 cloud_print::PlatformJobId& local_job_id,
32 const std::string& auth_token,
33 Delegate* delegate);
34 // Checks the status of the local print job and sends an update.
35 void UpdateStatus();
36 void Stop();
37 // URLFetcher::Delegate implementation.
38 virtual void OnURLFetchComplete(const URLFetcher* source, const GURL& url,
39 const URLRequestStatus& status,
40 int response_code,
41 const ResponseCookies& cookies,
42 const std::string& data);
43 private:
44 std::string printer_name_;
45 std::string job_id_;
46 cloud_print::PlatformJobId local_job_id_;
47 cloud_print::PrintJobDetails last_job_details_;
48 scoped_ptr<URLFetcher> request_;
49 std::string auth_token_;
50 Delegate* delegate_;
51 // A flag that is set to true in Stop() and will ensure the next scheduled
52 // task will do nothing.
53 bool stopped_;
54 DISALLOW_COPY_AND_ASSIGN(JobStatusUpdater);
55 };
56
57 // This typedef is to workaround the issue with certain versions of
58 // Visual Studio where it gets confused between multiple Delegate
59 // classes and gives a C2500 error. (I saw this error on the try bots -
60 // the workaround was not needed for my machine).
61 typedef JobStatusUpdater::Delegate JobStatusUpdaterDelegate;
62
63 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698