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

Unified Diff: mojo/application/public/cpp/application_impl.h

Issue 1455833005: Convert ConnectToApplication to take a params class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 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
« no previous file with comments | « mojo/application/public/cpp/BUILD.gn ('k') | mojo/application/public/cpp/lib/application_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/application/public/cpp/application_impl.h
diff --git a/mojo/application/public/cpp/application_impl.h b/mojo/application/public/cpp/application_impl.h
index 90e795968cd1773da4d1a238417b88ca1f7f90bc..1958461d786874dac8f79e2f027cc2f7bc54ebc7 100644
--- a/mojo/application/public/cpp/application_impl.h
+++ b/mojo/application/public/cpp/application_impl.h
@@ -7,6 +7,7 @@
#include <vector>
+#include "base/macros.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "mojo/application/public/cpp/app_lifetime_helper.h"
@@ -57,6 +58,25 @@ namespace mojo {
//
class ApplicationImpl : public Application {
public:
+ class ConnectParams {
+ public:
+ explicit ConnectParams(const std::string& url);
+ explicit ConnectParams(URLRequestPtr request);
+ ~ConnectParams();
+
+ URLRequestPtr TakeRequest() { return request_.Pass(); }
+ CapabilityFilterPtr TakeFilter() { return filter_.Pass(); }
+ void set_filter(CapabilityFilterPtr filter) {
+ filter_ = filter.Pass();
+ }
+
+ private:
+ URLRequestPtr request_;
+ CapabilityFilterPtr filter_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConnectParams);
+ };
+
class TestApi {
public:
explicit TestApi(ApplicationImpl* application)
@@ -97,22 +117,22 @@ class ApplicationImpl : public Application {
// or nullptr otherwise. Caller takes ownership.
scoped_ptr<ApplicationConnection> ConnectToApplication(
const std::string& url);
- scoped_ptr<ApplicationConnection> ConnectToApplication(URLRequestPtr request);
- scoped_ptr<ApplicationConnection> ConnectToApplicationWithCapabilityFilter(
- URLRequestPtr request,
- CapabilityFilterPtr filter);
+ scoped_ptr<ApplicationConnection> ConnectToApplication(ConnectParams* params);
// Connect to application identified by |request->url| and connect to the
// service implementation of the interface identified by |Interface|.
template <typename Interface>
- void ConnectToService(mojo::URLRequestPtr request,
- InterfacePtr<Interface>* ptr) {
- scoped_ptr<ApplicationConnection> connection =
- ConnectToApplication(request.Pass());
+ void ConnectToService(ConnectParams* params, InterfacePtr<Interface>* ptr) {
+ scoped_ptr<ApplicationConnection> connection = ConnectToApplication(params);
if (!connection.get())
return;
connection->ConnectToService(ptr);
}
+ template <typename Interface>
+ void ConnectToService(const std::string& url, InterfacePtr<Interface>* ptr) {
+ ConnectParams params(url);
+ return ConnectToService(&params, ptr);
+ }
// Block the calling thread until the Initialize() method is called by the
// shell.
« no previous file with comments | « mojo/application/public/cpp/BUILD.gn ('k') | mojo/application/public/cpp/lib/application_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698