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
3 // found in the LICENSE file.
5 #ifndef MOJO_APPS_JS_CONTENT_HANDLER_H_
6 #define MOJO_APPS_JS_CONTENT_HANDLER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h"
10 #include "mojo/public/cpp/application/application_delegate.h"
11 #include "mojo/public/cpp/system/message_pipe.h"
19 class ApplicationDelegateImpl
;
22 // Manages the JSApps started by this content handler. This class owns the one
23 // reference to the Mojo shell. JSApps post a task to the content handler's
24 // thread to connect to a service or to quit.
26 // The lifetime each JSApp is defined by its entry in AppVector. When the entry
27 // is removed ("erased") by QuitJSApp(), the JSApp is destroyed.
29 class ApplicationDelegateImpl
: public ApplicationDelegate
{
31 ApplicationDelegateImpl();
32 ~ApplicationDelegateImpl() override
;
34 // Add app to the AppVector and call its Start() method.
35 void StartJSApp(scoped_ptr
<JSApp
> app
);
37 // Remove app from the AppVector; destroys the app.
38 void QuitJSApp(JSApp
*app
);
40 void ConnectToService(ScopedMessagePipeHandle pipe_handle
,
41 const std::string
& application_url
,
42 const std::string
& interface_name
);
45 // ApplicationDelegate:
46 void Initialize(ApplicationImpl
* app
) override
;
49 typedef ScopedVector
<JSApp
> AppVector
;
50 ApplicationImpl
* application_impl_
;
51 AppVector app_vector_
;
57 #endif // MOJO_APPS_JS_CONTENT_HANDLER_H_