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

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

Issue 469883002: Using API key specified from js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing API build 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
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 18 matching lines...) Expand all
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). A pointer to this HttpPost object is also passed along.
36 typedef base::Callback<void(int, const std::string&)> 36 typedef base::Callback<void(int, const std::string&)>
37 ResponseCallback; 37 ResponseCallback;
38 38
39 // An id for testing url fetching. 39 // Create a request to the Copresence server.
40 static const int kUrlFetcherId = 1; 40 // |url_context_getter| is owned by the caller,
41 41 // and the context it provides must be available until the request completes.
42 // The query parameter to send Apiary tracing tokens.
43 static const char kTracingTokenField[];
44
45 // Create a request to the Copresence server. |url_context_getter|
46 // is owned by the caller, and the context it provides must be available
47 // until the request completes.
48 HttpPost(net::URLRequestContextGetter* url_context_getter, 42 HttpPost(net::URLRequestContextGetter* url_context_getter,
49 const std::string& server_host, 43 const std::string& server_host,
50 const std::string& rpc_name, 44 const std::string& rpc_name,
51 const std::string& tracing_token, 45 const std::string& tracing_token,
46 std::string api_key, // If blank, we overwrite with a default.
52 const google::protobuf::MessageLite& request_proto); 47 const google::protobuf::MessageLite& request_proto);
53 48
54 // HTTP requests are cancelled on delete. 49 // HTTP requests are cancelled on delete.
55 virtual ~HttpPost(); 50 virtual ~HttpPost();
56 51
57 // Send an HttpPost request. 52 // Send an HttpPost request.
58 void Start(const ResponseCallback& response_callback); 53 void Start(const ResponseCallback& response_callback);
59 54
60 private: 55 private:
56 static const int kUrlFetcherId = 1;
57 static const char kApiKeyField[];
58 static const char kTracingTokenField[];
59
60 friend class HttpPostTest;
61
61 // Overridden from net::URLFetcherDelegate. 62 // Overridden from net::URLFetcherDelegate.
62 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 63 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
63 64
64 ResponseCallback response_callback_; 65 ResponseCallback response_callback_;
66
65 scoped_ptr<net::URLFetcher> url_fetcher_; 67 scoped_ptr<net::URLFetcher> url_fetcher_;
66 68
67 DISALLOW_COPY_AND_ASSIGN(HttpPost); 69 DISALLOW_COPY_AND_ASSIGN(HttpPost);
68 }; 70 };
69 71
70 } // namespace copresence 72 } // namespace copresence
71 73
72 #endif // COMPONENTS_COPRESENCE_RPC_HTTP_POST_H_ 74 #endif // COMPONENTS_COPRESENCE_RPC_HTTP_POST_H_
OLDNEW
« no previous file with comments | « components/copresence/public/copresence_client_delegate.h ('k') | components/copresence/rpc/http_post.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698