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

Side by Side Diff: mojo/application_manager/application_loader.h

Issue 741453002: Make sure that Content Handled application can be connected multiple times. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix sky Created 6 years 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
« no previous file with comments | « no previous file | mojo/application_manager/application_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 MOJO_APPLICATION_MANAGER_APPLICATION_LOADER_H_ 5 #ifndef MOJO_APPLICATION_MANAGER_APPLICATION_LOADER_H_
6 #define MOJO_APPLICATION_MANAGER_APPLICATION_LOADER_H_ 6 #define MOJO_APPLICATION_MANAGER_APPLICATION_LOADER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/callback.h"
9 #include "mojo/application_manager/application_manager_export.h" 9 #include "mojo/application_manager/application_manager_export.h"
10 #include "mojo/public/cpp/system/core.h" 10 #include "mojo/public/cpp/system/core.h"
11 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" 11 #include "mojo/services/public/interfaces/network/url_loader.mojom.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 15
16 class ApplicationManager; 16 class ApplicationManager;
17 17
18 // Interface to allowing loading behavior to be established for schemes, 18 // Interface to allowing loading behavior to be established for schemes,
19 // specific urls or as the default. 19 // specific urls or as the default.
20 // A ApplicationLoader is responsible to using whatever mechanism is appropriate 20 // A ApplicationLoader is responsible to using whatever mechanism is appropriate
21 // to load the application at url. 21 // to load the application at url.
22 // The handle to the shell is passed to that application so it can bind it to 22 // The handle to the shell is passed to that application so it can bind it to
23 // a Shell instance. This will give the Application a way to connect to other 23 // a Shell instance. This will give the Application a way to connect to other
24 // apps and services. 24 // apps and services.
25 class MOJO_APPLICATION_MANAGER_EXPORT ApplicationLoader { 25 class MOJO_APPLICATION_MANAGER_EXPORT ApplicationLoader {
26 public: 26 public:
27 class MOJO_APPLICATION_MANAGER_EXPORT LoadCallbacks 27 typedef base::Callback<
28 : public base::RefCounted<LoadCallbacks> { 28 void(const GURL&, ScopedMessagePipeHandle, URLResponsePtr)> LoadCallback;
29 public: 29 virtual ~ApplicationLoader() {}
30 // Register the requested application with ApplicationManager. If the
31 // returned handle is valid, it should be used to implement the
32 // mojo::Application interface.
33 virtual ScopedMessagePipeHandle RegisterApplication() = 0;
34 30
35 // Load the requested application with a content handler. 31 // Returns a callback that will should never be called.
36 virtual void LoadWithContentHandler(const GURL& content_handler_url, 32 static LoadCallback SimpleLoadCallback();
37 URLResponsePtr url_response) = 0;
38
39 protected:
40 friend base::RefCounted<LoadCallbacks>;
41 virtual ~LoadCallbacks() {}
42 };
43
44 // Implements RegisterApplication() by returning a handle that was specified
45 // at construction time. LoadWithContentHandler() is not supported.
46 class MOJO_APPLICATION_MANAGER_EXPORT SimpleLoadCallbacks
47 : public LoadCallbacks {
48 public:
49 SimpleLoadCallbacks(ScopedMessagePipeHandle shell_handle);
50 ScopedMessagePipeHandle RegisterApplication() override;
51 void LoadWithContentHandler(const GURL& content_handler_url,
52 URLResponsePtr response) override;
53
54 private:
55 ScopedMessagePipeHandle shell_handle_;
56 ~SimpleLoadCallbacks() override;
57 };
58
59 virtual ~ApplicationLoader() {}
60 33
61 // Load the application named |url|. Applications can be loaded two ways: 34 // Load the application named |url|. Applications can be loaded two ways:
62 // 35 //
63 // 1. |url| can refer directly to a Mojo application. In this case, call 36 // 1. |url| can refer directly to a Mojo application. In this case,
64 // callbacks->RegisterApplication(). The returned handle should be used to 37 // shell_handle should be used to implement the mojo.Application interface.
65 // implement the mojo.Application interface. Note that the returned handle
66 // can be invalid in the case where the application has already been
67 // loaded.
68 // 38 //
69 // 2. |url| can refer to some content that can be handled by some other Mojo 39 // 2. |url| can refer to some content that can be handled by some other Mojo
70 // application. In this case, call callbacks->LoadWithContentHandler() and 40 // application. In this case, call callbacks and specify the URL of the
71 // specify the URL of the application that should handle the content. 41 // application that should handle the content. The specified application
72 // The specified application must implement the mojo.ContentHandler 42 // must implement the mojo.ContentHandler interface.
73 // interface.
74 virtual void Load(ApplicationManager* application_manager, 43 virtual void Load(ApplicationManager* application_manager,
75 const GURL& url, 44 const GURL& url,
76 scoped_refptr<LoadCallbacks> callbacks) = 0; 45 ScopedMessagePipeHandle shell_handle,
46 LoadCallback callback) = 0;
77 47
78 // Called when the Application exits. 48 // Called when the Application exits.
79 virtual void OnApplicationError(ApplicationManager* manager, 49 virtual void OnApplicationError(ApplicationManager* manager,
80 const GURL& url) = 0; 50 const GURL& url) = 0;
81 51
82 protected: 52 protected:
83 ApplicationLoader() {} 53 ApplicationLoader() {}
84 }; 54 };
85 55
86 } // namespace mojo 56 } // namespace mojo
87 57
88 #endif // MOJO_APPLICATION_MANAGER_APPLICATION_LOADER_H_ 58 #endif // MOJO_APPLICATION_MANAGER_APPLICATION_LOADER_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/application_manager/application_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698