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

Unified Diff: components/copresence/rpc/rpc_handler.h

Issue 685983007: RpcHandlerTest cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: components/copresence/rpc/rpc_handler.h
diff --git a/components/copresence/rpc/rpc_handler.h b/components/copresence/rpc/rpc_handler.h
index 32213671e209edf4033ec04b33faa2032b776052..fca80ebe71073966fb20f793d62e49f6c2511bc9 100644
--- a/components/copresence/rpc/rpc_handler.h
+++ b/components/copresence/rpc/rpc_handler.h
@@ -31,12 +31,38 @@ class RpcHandler {
// A callback to indicate whether handler initialization succeeded.
typedef base::Callback<void(bool)> SuccessCallback;
+ // An HttpPost::ResponseCallback along with an HttpPost object to be deleted.
+ // Arguments:
+ // HttpPost*: The handler should take ownership of (i.e. delete) this object.
+ // int: The HTTP status code of the response.
+ // string: The contents of the response.
+ typedef base::Callback<void(HttpPost*, int, const std::string&)>
+ PostCleanupCallback;
+
+ // Callback to allow tests to stub out HTTP POST behavior.
+ // Arguments:
+ // URLRequestContextGetter: Context for the HTTP POST request.
+ // string: Name of the rpc to invoke. URL format: server.google.com/rpc_name
+ // string: The API key to pass in the request.
+ // string: The auth token to pass with the request.
+ // MessageLite: Contents of POST request to be sent. This needs to be
+ // a (scoped) pointer to ease handling of the abstract MessageLite class.
+ // PostCleanupCallback: Receives the response to the request.
+ typedef base::Callback<void(net::URLRequestContextGetter*,
+ const std::string&,
+ const std::string&,
+ const std::string&,
+ scoped_ptr<google::protobuf::MessageLite>,
+ const PostCleanupCallback&)> PostCallback;
+
// Report rpc name to send to Apiary.
static const char kReportRequestRpcName[];
// Constructor. |delegate| and |directive_handler|
// are owned by the caller and must outlive the RpcHandler.
- RpcHandler(CopresenceDelegate* delegate, DirectiveHandler* directive_handler);
+ RpcHandler(CopresenceDelegate* delegate,
+ DirectiveHandler* directive_handler,
+ const PostCallback& server_post_callback = PostCallback());
virtual ~RpcHandler();
@@ -66,30 +92,6 @@ class RpcHandler {
void ReportTokens(const std::vector<AudioToken>& tokens);
private:
- // An HttpPost::ResponseCallback along with an HttpPost object to be deleted.
- // Arguments:
- // HttpPost*: The handler should take ownership of (i.e. delete) this object.
- // int: The HTTP status code of the response.
- // string: The contents of the response.
- typedef base::Callback<void(HttpPost*, int, const std::string&)>
- PostCleanupCallback;
-
- // Callback to allow tests to stub out HTTP POST behavior.
- // Arguments:
- // URLRequestContextGetter: Context for the HTTP POST request.
- // string: Name of the rpc to invoke. URL format: server.google.com/rpc_name
- // string: The API key to pass in the request.
- // string: The auth token to pass with the request.
- // MessageLite: Contents of POST request to be sent. This needs to be
- // a (scoped) pointer to ease handling of the abstract MessageLite class.
- // PostCleanupCallback: Receives the response to the request.
- typedef base::Callback<void(net::URLRequestContextGetter*,
- const std::string&,
- const std::string&,
- const std::string&,
- scoped_ptr<google::protobuf::MessageLite>,
- const PostCleanupCallback&)> PostCallback;
-
friend class RpcHandlerTest;
// Server call response handlers.
@@ -143,7 +145,6 @@ class RpcHandler {
TimedMap<std::string, bool> invalid_audio_token_cache_;
- // TODO(ckehoe): Allow passing this into the constructor for testing.
PostCallback server_post_callback_;
std::map<std::string, std::string> device_id_by_auth_token_;

Powered by Google App Engine
This is Rietveld 408576698