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

Side by Side Diff: components/copresence/rpc/http_post.h

Issue 453793002: Add audible support to the copresence API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_COPRESENCE_RPC_HTTP_POST_H_ 5 #ifndef COMPONENTS_COPRESENCE_RPC_HTTP_POST_H_
6 #define COMPONENTS_COPRESENCE_RPC_HTTP_POST_H_ 6 #define COMPONENTS_COPRESENCE_RPC_HTTP_POST_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 14 matching lines...) Expand all
25 namespace copresence { 25 namespace copresence {
26 26
27 // This class handles all Apiary calls to the Copresence server. 27 // This class handles all Apiary calls to the Copresence server.
28 // It configures the HTTP request appropriately and reports any errors. 28 // It configures the HTTP request appropriately and reports any errors.
29 // If deleted, the HTTP request is cancelled. 29 // If deleted, the HTTP request is cancelled.
30 // 30 //
31 // TODO(ckehoe): Add retry logic. 31 // TODO(ckehoe): Add retry logic.
32 class HttpPost : public net::URLFetcherDelegate { 32 class HttpPost : public net::URLFetcherDelegate {
33 public: 33 public:
34 // Callback to receive the HTTP status code and body of the response 34 // Callback to receive the HTTP status code and body of the response
35 // (if any). A pointer to this HttpPost object is also passed along. 35 // (if any).
36 typedef base::Callback<void(int, const std::string&, HttpPost*)> 36 typedef base::Callback<void(int, const std::string&)> ResponseCallback;
37 ResponseCallback;
38 37
39 // An id for testing url fetching. 38 // An id for testing url fetching.
40 static const int kUrlFetcherId = 1; 39 static const int kUrlFetcherId = 1;
41 40
42 // Send a request to the Copresence server. After calling the callback, this 41 // Send a request to the Copresence server. After calling the callback, this
43 // object will delete itself. |url_context_getter| is owned by the caller, 42 // object will delete itself. |url_context_getter| is owned by the caller,
44 // and the context it provides must be available until the request completes. 43 // and the context it provides must be available until the request completes.
45 // If this context is being destructed, call Cancel(). 44 // If this context is being destructed, call Cancel().
46 HttpPost(net::URLRequestContextGetter* url_context_getter, 45 HttpPost(net::URLRequestContextGetter* url_context_getter,
47 const std::string& server_host, 46 const std::string& server_host,
48 const std::string& rpc_name, 47 const std::string& rpc_name,
49 const google::protobuf::MessageLite& request_proto, 48 const google::protobuf::MessageLite& request_proto);
50 const ResponseCallback& response_callback); 49
50 void Start(const ResponseCallback& response_callback);
51 51
52 // HTTP requests are cancelled on delete. 52 // HTTP requests are cancelled on delete.
53 virtual ~HttpPost(); 53 virtual ~HttpPost();
54 54
55 private: 55 private:
56 // Overridden from net::URLFetcherDelegate. 56 // Overridden from net::URLFetcherDelegate.
57 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 57 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
58 58
59 ResponseCallback response_callback_; 59 ResponseCallback response_callback_;
60 scoped_ptr<net::URLFetcher> url_fetcher_; 60 scoped_ptr<net::URLFetcher> url_fetcher_;
61 61
62 DISALLOW_COPY_AND_ASSIGN(HttpPost); 62 DISALLOW_COPY_AND_ASSIGN(HttpPost);
63 }; 63 };
64 64
65 } // namespace copresence 65 } // namespace copresence
66 66
67 #endif // COMPONENTS_COPRESENCE_RPC_HTTP_POST_H_ 67 #endif // COMPONENTS_COPRESENCE_RPC_HTTP_POST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698