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

Side by Side Diff: chrome/service/cloud_print/cloud_print_helpers.h

Issue 4165013: Re-landing issue 4202006 (http://codereview.chromium.org/4202006/show) which ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ 6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 22 matching lines...) Expand all
33 cloud_print::PrintJobStatus status); 33 cloud_print::PrintJobStatus status);
34 static GURL GetUrlForJobStatusUpdate( 34 static GURL GetUrlForJobStatusUpdate(
35 const GURL& cloud_print_server_url, const std::string& job_id, 35 const GURL& cloud_print_server_url, const std::string& job_id,
36 const cloud_print::PrintJobDetails& details); 36 const cloud_print::PrintJobDetails& details);
37 // Parses the response data for any cloud print server request. The method 37 // Parses the response data for any cloud print server request. The method
38 // returns false if there was an error in parsing the JSON. The succeeded 38 // returns false if there was an error in parsing the JSON. The succeeded
39 // value returns the value of the "success" value in the response JSON. 39 // value returns the value of the "success" value in the response JSON.
40 // Returns the response as a dictionary value. 40 // Returns the response as a dictionary value.
41 static bool ParseResponseJSON(const std::string& response_data, 41 static bool ParseResponseJSON(const std::string& response_data,
42 bool* succeeded, DictionaryValue** response_dict); 42 bool* succeeded, DictionaryValue** response_dict);
43 // Sets up common parameters for a cloud print request 43
44 // (such as the GAIA auth token in the request headers, the request context
45 // etc).
46 static void PrepCloudPrintRequest(URLFetcher* request,
47 const std::string& auth_token);
48 // Strictly speaking, this helper method is not specific to cloud printing.
49 // It handles the logic to retry tasks when the server returns an error.
50 // The parameters are as below:
51 // |error_count| Contains the current number of consecutive failed attempts.
52 // This method increments it (in/out)
53 // |max_retry_count| Number of retries before giving up. -1 implies no limit.
54 // |max_retry_interval| Maximum amount of time (in ms) we are willing to
55 // wait between retries. -1 implies no limit.
56 // |base_retry_interval| Starting value of the retry interval. This
57 // method progressively increases the interval on each retry.
58 // |task_to_retry| The task to be retried.
59 // |task_on_give_up| Task to be performed when we give up. This is only
60 // valid when max_retry_count is not -1. It can be NULL.
61 static void HandleServerError(int* error_count, int max_retry_count,
62 int64 max_retry_interval,
63 int64 base_retry_interval,
64 Task* task_to_retry, Task* task_on_give_up);
65 // Prepares one value as part of a multi-part upload request. 44 // Prepares one value as part of a multi-part upload request.
66 static void AddMultipartValueForUpload( 45 static void AddMultipartValueForUpload(
67 const std::string& value_name, const std::string& value, 46 const std::string& value_name, const std::string& value,
68 const std::string& mime_boundary, const std::string& content_type, 47 const std::string& mime_boundary, const std::string& content_type,
69 std::string* post_data); 48 std::string* post_data);
70 // Create a MIME boundary marker (27 '-' characters followed by 16 hex digits). 49 // Create a MIME boundary marker (27 '-' characters followed by 16 hex digits).
71 static void CreateMimeBoundaryForUpload(std::string *out); 50 static void CreateMimeBoundaryForUpload(std::string *out);
72 // Generates an MD5 hash of the contents of a string map. 51 // Generates an MD5 hash of the contents of a string map.
73 static std::string GenerateHashOfStringMap( 52 static std::string GenerateHashOfStringMap(
74 const std::map<std::string, std::string>& string_map); 53 const std::map<std::string, std::string>& string_map);
75 static void GenerateMultipartPostDataForPrinterTags( 54 static void GenerateMultipartPostDataForPrinterTags(
76 const std::map<std::string, std::string>& printer_tags, 55 const std::map<std::string, std::string>& printer_tags,
77 const std::string& mime_boundary, 56 const std::string& mime_boundary,
78 std::string* post_data); 57 std::string* post_data);
79 58
80 private: 59 private:
81 CloudPrintHelpers() { 60 CloudPrintHelpers() {
82 } 61 }
83 }; 62 };
84 63
85 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ 64 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
86 65
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_consts.cc ('k') | chrome/service/cloud_print/cloud_print_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698