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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/printing/cloud_print/job_status_updater.h
===================================================================
--- chrome/browser/printing/cloud_print/job_status_updater.h (revision 0)
+++ chrome/browser/printing/cloud_print/job_status_updater.h (revision 0)
@@ -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_BROWSER_PRINTING_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
+#define CHROME_BROWSER_PRINTING_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
+
+#include <string>
+
+#include "base/file_path.h"
+#include "base/ref_counted.h"
+#include "base/thread.h"
+#include "chrome/browser/printing/cloud_print/printer_info.h"
+#include "chrome/browser/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_BROWSER_PRINTING_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
+
Property changes on: chrome\browser\printing\cloud_print\job_status_updater.h
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698