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

Unified Diff: chrome/browser/printing/cloud_print/cloud_print_helpers.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/cloud_print_helpers.h
===================================================================
--- chrome/browser/printing/cloud_print/cloud_print_helpers.h (revision 0)
+++ chrome/browser/printing/cloud_print/cloud_print_helpers.h (revision 0)
@@ -0,0 +1,71 @@
+// 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_CLOUD_PRINT_HELPERS_H_
+#define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
+
+#include <string>
+
+#include "chrome/browser/printing/cloud_print/printer_info.h"
+#include "googleurl/src/gurl.h"
+
+class DictionaryValue;
+class Task;
+class URLFetcher;
+
+// Helper methods for the cloud print proxy code.
+class CloudPrintHelpers {
+ public:
+ static GURL GetUrlForPrinterRegistration();
+ static GURL GetUrlForPrinterUpdate(const std::string& printer_id);
+ static GURL GetUrlForPrinterDelete(const std::string& printer_id);
+ static GURL GetUrlForPrinterList(const std::string& proxy_id);
+ static GURL GetUrlForJobFetch(const std::string& printer_id);
+ static GURL GetUrlForJobStatusUpdate(const std::string& job_id,
+ cloud_print::PrintJobStatus status);
+ static GURL GetUrlForJobStatusUpdate(
+ const std::string& job_id, const cloud_print::PrintJobDetails& details);
+ // Parses the response data for any cloud print server request. The method
+ // returns false if there was an error in parsing the JSON. The succeeded
+ // value returns the value of the "success" value in the response JSON.
+ // Returns the response as a dictionary value.
+ static bool ParseResponseJSON(const std::string& response_data,
+ bool* succeeded, DictionaryValue** response_dict);
+ // Sets up common parameters for a cloud print request
+ // (such as the GAIA auth token in the request headers, the request context
+ // etc).
+ static void PrepCloudPrintRequest(URLFetcher* request,
+ const std::string& auth_token);
+ // Strictly speaking, this helper method is not specific to cloud printing.
+ // It handles the logic to retry tasks when the server returns an error.
+ // The parameters are as below:
+ // |error_count| Contains the current number of consecutive failed attempts.
+ // This method increments it (in/out)
+ // |max_retry_count| Number of retries before giving up. -1 implies no limit.
+ // |max_retry_interval| Maximum amount of time (in ms) we are willing to
+ // wait between retries. -1 implies no limit.
+ // |base_retry_interval| Starting value of the retry interval. This
+ // method progressively increases the interval on each retry.
+ // |task_to_retry| The task to be retried.
+ // |task_on_give_up| Task to be performed when we give up. This is only
+ // valid when max_retry_count is not -1. It can be NULL.
+ static void HandleServerError(int* error_count, int max_retry_count,
+ int64 max_retry_interval,
+ int64 base_retry_interval,
+ Task* task_to_retry, Task* task_on_give_up);
+ // Prepares one value as part of a multi-part upload request.
+ static void AddMultipartValueForUpload(
+ const std::string& value_name, const std::string& value,
+ const std::string& mime_boundary, const std::string& content_type,
+ std::string* post_data);
+// Create a MIME boundary marker (27 '-' characters followed by 16 hex digits).
+ static void CreateMimeBoundaryForUpload(std::string *out);
+
+ private:
+ CloudPrintHelpers() {
+ }
+};
+
+#endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
+
Property changes on: chrome\browser\printing\cloud_print\cloud_print_helpers.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/printing/cloud_print/cloud_print_consts.cc ('k') | chrome/browser/printing/cloud_print/cloud_print_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698