1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MOJO_SHELL_CONTENT_HANDLER_CONNECTION_H_
6 #define MOJO_SHELL_CONTENT_HANDLER_CONNECTION_H_
10 #include "mojo/application/public/interfaces/content_handler.mojom.h"
11 #include "mojo/shell/capability_filter.h"
17 class ApplicationManager
;
20 // A ContentHandlerConnection is responsible for creating and maintaining a
21 // connection to an app which provides the ContentHandler service.
22 // A ContentHandlerConnection can only be destroyed via CloseConnection.
23 // A ContentHandlerConnection manages its own lifetime and cannot be used with
24 // a scoped_ptr to avoid reentrant calls into ApplicationManager late in
26 class ContentHandlerConnection
{
28 // |id| is a unique identifier for this content handler.
29 ContentHandlerConnection(ApplicationManager
* manager
,
30 const Identity
& originator_identity
,
31 const CapabilityFilter
& originator_filter
,
32 const GURL
& content_handler_url
,
33 const std::string
& qualifier
,
34 const CapabilityFilter
& filter
,
37 // Closes the connection and destroys |this| object.
38 void CloseConnection();
40 ContentHandler
* content_handler() { return content_handler_
.get(); }
41 const GURL
& content_handler_url() { return content_handler_url_
; }
42 const std::string
& content_handler_qualifier() {
43 return content_handler_qualifier_
;
45 uint32_t id() const { return id_
; }
48 ~ContentHandlerConnection();
50 ApplicationManager
* manager_
;
51 GURL content_handler_url_
;
52 std::string content_handler_qualifier_
;
53 ContentHandlerPtr content_handler_
;
54 bool connection_closed_
;
55 // The id for this content handler.
58 DISALLOW_COPY_AND_ASSIGN(ContentHandlerConnection
);
64 #endif // MOJO_SHELL_CONTENT_HANDLER_CONNECTION_H_