2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "runtime/browser/preload_manager.h"
19 #include <Elementary.h>
21 #include <EWebKit_internal.h>
24 #include "common/logger.h"
25 #include "runtime/browser/native_app_window.h"
26 #include "extensions/common/xwalk_extension_server.h"
28 #ifndef INJECTED_BUNDLE_PATH
29 #error INJECTED_BUNDLE_PATH is not set.
34 PreloadManager* PreloadManager::GetInstance() {
35 static PreloadManager instance;
39 PreloadManager::PreloadManager() {
42 void PreloadManager::CreateCacheComponet() {
43 // Load extensions in the preload step
44 auto extension_server = extensions::XWalkExtensionServer::GetInstance();
45 extension_server->Preload();
47 // It was not used. just to fork zygote process
49 ewk_context_new_with_injected_bundle_path(INJECTED_BUNDLE_PATH);
50 context = context; // To prevent build warning
51 cached_window_.reset(new NativeAppWindow());
52 cached_window_->Initialize();
55 NativeWindow* PreloadManager::GetCachedNativeWindow() {
56 return cached_window_ ? cached_window_.release() : nullptr;
59 void PreloadManager::ReleaseCachedNativeWindow() {
60 cached_window_.reset(nullptr);
63 } // namespace runtime