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

Unified Diff: cloud_print/gcp20/prototype/cloud_print_request.h

Issue 19866002: GCP2.0 Device: Receiving printjobs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@confirmation
Patch Set: static_cast<int> Created 7 years, 5 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
« no previous file with comments | « no previous file | cloud_print/gcp20/prototype/cloud_print_request.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cloud_print/gcp20/prototype/cloud_print_request.h
diff --git a/cloud_print/gcp20/prototype/cloud_print_request.h b/cloud_print/gcp20/prototype/cloud_print_request.h
new file mode 100644
index 0000000000000000000000000000000000000000..5adfe354065878b735ff63dfe63e8aa1f541a843
--- /dev/null
+++ b/cloud_print/gcp20/prototype/cloud_print_request.h
@@ -0,0 +1,79 @@
+// Copyright 2013 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 CLOUD_PRINT_GCP20_PROTOTYPE_CLOUD_PRINT_REQUEST_H_
+#define CLOUD_PRINT_GCP20_PROTOTYPE_CLOUD_PRINT_REQUEST_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/memory/weak_ptr.h"
+#include "net/url_request/url_fetcher.h"
+#include "net/url_request/url_fetcher_delegate.h"
+
+// Request to CloudPrint with timeout control.
+// Delegate should delete this object once it is deleting.
+class CloudPrintRequest : public net::URLFetcherDelegate,
+ public base::SupportsWeakPtr<CloudPrintRequest> {
+ public:
+ class Delegate {
+ public:
+ Delegate() {}
+ virtual ~Delegate() {}
+
+ // Invoked when |fetcher_| finished fetching successfully.
+ // Use for erasing instance of CloudPrintRequest class.
+ virtual void OnFetchComplete(const std::string& response) = 0;
+
+ // Invoked when |fetcher_| finished fetching successfully.
+ // Use for erasing instance of CloudPrintRequest class.
+ virtual void OnFetchError(const std::string& server_api,
+ int server_code,
+ int server_http_code) = 0;
+
+ // Invoked when timeout is reached.
+ // Use for erasing instance of CloudPrintRequest class.
+ virtual void OnFetchTimeoutReached() = 0;
+ };
+
+ virtual ~CloudPrintRequest();
+
+ // Creates GET request.
+ static scoped_ptr<CloudPrintRequest> CreateGet(const GURL& url,
+ Delegate* delegate);
+
+ // Creates POST request.
+ static scoped_ptr<CloudPrintRequest> CreatePost(const GURL& url,
+ const std::string& content,
+ const std::string& mimetype,
+ Delegate* delegate);
+
+ // Starts request. Once fetch was completed, parser will be called.
+ void Run(const std::string& access_token,
+ scoped_refptr<net::URLRequestContextGetter> context_getter);
+
+ // Add header to request.
+ void AddHeader(const std::string& header);
+
+ private:
+ CloudPrintRequest(const GURL& url,
+ net::URLFetcher::RequestType method,
+ Delegate* delegate);
+
+ // net::URLFetcherDelegate methods:
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+
+ // Method for handling timeout.
+ void OnRequestTimeout();
+
+ scoped_ptr<net::URLFetcher> fetcher_;
+
+ Delegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(CloudPrintRequest);
+};
+
+#endif // CLOUD_PRINT_GCP20_PROTOTYPE_CLOUD_PRINT_REQUEST_H_
+
« no previous file with comments | « no previous file | cloud_print/gcp20/prototype/cloud_print_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698