summaryrefslogtreecommitdiffstats
path: root/chrome/service/cloud_print/job_status_updater.h
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-13 17:18:01 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-13 17:18:01 +0000
commit8b50bd202626cf978685197adee0d8f32161443b (patch)
treefe543b2bba72103859baefb8e149814e3e35e2ee /chrome/service/cloud_print/job_status_updater.h
parentd94ccedd108876d5be652dfa8129df54cab555e9 (diff)
downloadchromium_src-8b50bd202626cf978685197adee0d8f32161443b.zip
chromium_src-8b50bd202626cf978685197adee0d8f32161443b.tar.gz
chromium_src-8b50bd202626cf978685197adee0d8f32161443b.tar.bz2
Moved cloud print code from the chrome/browser/printing/cloud_print to chrome/service/cloud_print
BUG=None. TEST=None. Review URL: http://codereview.chromium.org/2007012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47155 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service/cloud_print/job_status_updater.h')
-rw-r--r--chrome/service/cloud_print/job_status_updater.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/chrome/service/cloud_print/job_status_updater.h b/chrome/service/cloud_print/job_status_updater.h
new file mode 100644
index 0000000..d840b1c
--- /dev/null
+++ b/chrome/service/cloud_print/job_status_updater.h
@@ -0,0 +1,64 @@
+// Copyright (c) 2010 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.
+
+#ifndef CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
+#define CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
+
+#include <string>
+
+#include "base/file_path.h"
+#include "base/ref_counted.h"
+#include "base/thread.h"
+#include "chrome/service/cloud_print/printer_info.h"
+#include "chrome/common/net/url_fetcher.h"
+#include "net/url_request/url_request_status.h"
+
+// Periodically monitors the status of a local print job and updates the
+// cloud print server accordingly. When the job has been completed this
+// object releases the reference to itself which should cause it to
+// self-destruct.
+class JobStatusUpdater : public base::RefCountedThreadSafe<JobStatusUpdater>,
+ public URLFetcher::Delegate {
+ public:
+ class Delegate {
+ public:
+ virtual bool OnJobCompleted(JobStatusUpdater* updater) = 0;
+ };
+
+ JobStatusUpdater(const std::string& printer_name,
+ const std::string& job_id,
+ cloud_print::PlatformJobId& local_job_id,
+ const std::string& auth_token,
+ Delegate* delegate);
+ // Checks the status of the local print job and sends an update.
+ void UpdateStatus();
+ void Stop();
+ // URLFetcher::Delegate implementation.
+ virtual void OnURLFetchComplete(const URLFetcher* source, const GURL& url,
+ const URLRequestStatus& status,
+ int response_code,
+ const ResponseCookies& cookies,
+ const std::string& data);
+ private:
+ std::string printer_name_;
+ std::string job_id_;
+ cloud_print::PlatformJobId local_job_id_;
+ cloud_print::PrintJobDetails last_job_details_;
+ scoped_ptr<URLFetcher> request_;
+ std::string auth_token_;
+ Delegate* delegate_;
+ // A flag that is set to true in Stop() and will ensure the next scheduled
+ // task will do nothing.
+ bool stopped_;
+ DISALLOW_COPY_AND_ASSIGN(JobStatusUpdater);
+};
+
+// This typedef is to workaround the issue with certain versions of
+// Visual Studio where it gets confused between multiple Delegate
+// classes and gives a C2500 error. (I saw this error on the try bots -
+// the workaround was not needed for my machine).
+typedef JobStatusUpdater::Delegate JobStatusUpdaterDelegate;
+
+#endif // CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
+