Index: mojo/shell/content_handler_connection.h |
diff --git a/mojo/shell/content_handler_connection.h b/mojo/shell/content_handler_connection.h |
index 19952652af5fafcf225447c79b1b325e52b2db1d..74f7464cf92d0cf75a4732641487174577144f7e 100644 |
--- a/mojo/shell/content_handler_connection.h |
+++ b/mojo/shell/content_handler_connection.h |
@@ -7,7 +7,9 @@ |
#include <string> |
+#include "base/memory/weak_ptr.h" |
#include "mojo/application/public/interfaces/content_handler.mojom.h" |
+#include "mojo/application/public/interfaces/shell.mojom.h" |
#include "mojo/shell/capability_filter.h" |
#include "url/gurl.h" |
@@ -25,12 +27,14 @@ class ApplicationManager; |
// destruction. |
class ContentHandlerConnection { |
public: |
+ // |id| is a unique identifier for this content handler. |
ContentHandlerConnection(ApplicationInstance* originator, |
ApplicationManager* manager, |
const GURL& content_handler_url, |
const GURL& requestor_url, |
const std::string& qualifier, |
- const CapabilityFilter& filter); |
+ const CapabilityFilter& filter, |
+ uint32_t id); |
// Closes the connection and destroys |this| object. |
void CloseConnection(); |
@@ -40,15 +44,46 @@ class ContentHandlerConnection { |
const std::string& content_handler_qualifier() { |
return content_handler_qualifier_; |
} |
+ uint32_t id() const { return id_; } |
+ |
+ // Schedules a callback to be run once the id of any nested content handlers |
+ // are obtained. |
+ void ScheduleTargetIdCallback( |
Ben Goodger (Google)
2015/08/31 17:41:07
rename?
sky
2015/08/31 19:46:07
This was all nuked.
|
+ const Shell::ConnectToApplicationCallback& connect_callback); |
private: |
~ContentHandlerConnection(); |
+ // Callback from ConnectToApplication() on the target application. |
+ void OnGotNestedContentHandlerID(uint32_t content_handler_id); |
+ |
+ // Returns the id to supply to the callback from |
+ // Shell::ConnectToApplication(). The returned id is either the id of this |
+ // content handler, or if connecting to the application involved another |
+ // content handler, then the deepest id from that connection. |
+ // |
+ // This is only valid once OnGotNestedContentHandlerID() is received. |
+ uint32_t content_handler_id_for_callback() const; |
+ |
ApplicationManager* manager_; |
GURL content_handler_url_; |
std::string content_handler_qualifier_; |
ContentHandlerPtr content_handler_; |
bool connection_closed_; |
+ // The id for this content handler. |
+ const uint32_t id_; |
+ |
+ // Set to true once OnGotNestedContentHandlerID() has been invoked. At this |
+ // point |nested_content_handler_id_| is valid. |
+ bool got_nested_content_handler_id_; |
+ uint32_t nested_content_handler_id_; |
+ |
+ // Callbacks scheduled before OnGotNestedContentHandlerID() are added here. |
+ // Once OnGotNestedContentHandlerID() is called these are processed. |
+ std::vector<Shell::ConnectToApplicationCallback> |
+ pending_content_handler_id_callbacks_; |
+ |
+ base::WeakPtrFactory<ContentHandlerConnection> weak_ptr_factory_; |
DISALLOW_COPY_AND_ASSIGN(ContentHandlerConnection); |
}; |