#include "browser_context_efl.h"
+#include "base/bind.h"
#include "base/file_util.h"
#include "base/path_service.h"
#include "components/visitedlink/browser/visitedlink_master.h"
browser_context_(ctx) {
}
+BrowserContextEfl::~BrowserContextEfl() {
+ if (resource_context_) {
+ DCHECK(BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, resource_context_));
+ resource_context_ = NULL;
+ }
+}
+
BrowserContextEfl::ResourceContextEfl::~ResourceContextEfl() {
}
}
BrowserContextEfl::BrowserContextEfl(EWebContext* web_context)
- : web_context_(web_context),
+ : resource_context_(NULL),
+ web_context_(web_context),
#if defined(ENABLE_NOTIFICATIONS)
notification_controllerefl_(new NotificationControllerEfl()),
#endif
ResourceContext* BrowserContextEfl::GetResourceContext() {
if (!resource_context_)
- resource_context_.reset(new ResourceContextEfl(this));
+ resource_context_ = new ResourceContextEfl(this);
- return resource_context_.get();
+ return resource_context_;
}
base::FilePath BrowserContextEfl::GetPath() const {
public visitedlink::VisitedLinkDelegate {
public:
BrowserContextEfl(EWebContext*);
+ ~BrowserContextEfl();
virtual bool IsOffTheRecord() const OVERRIDE { return false; }
virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
static void ReadCertificateAndAdd(base::FilePath* file_path);
scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_;
- scoped_ptr<ResourceContextEfl> resource_context_;
+ ResourceContextEfl* resource_context_;
scoped_refptr<URLRequestContextGetterEfl> request_context_getter_;
EWebContext* web_context_;
#if defined(ENABLE_NOTIFICATIONS)
namespace content {
-BrowserMainPartsEfl::BrowserMainPartsEfl() {
+BrowserMainPartsEfl::BrowserMainPartsEfl()
+ : devtools_delegate_(NULL) {
}
BrowserMainPartsEfl::~BrowserMainPartsEfl() {
'eweb_view.cc',
'eweb_view.h',
'eweb_view_callbacks.h',
+ 'ewk_global_data.h',
+ 'ewk_global_data.cc',
'file_chooser_controller_efl.cc',
'file_chooser_controller_efl.h',
'memory_purger.cc',
#include "eweb_context.h"
-#include "base/command_line.h"
-#include "base/files/file_path.h"
-#include "base/path_service.h"
-#include "base/logging.h"
-#include "base/threading/thread_restrictions.h"
+#include "base/synchronization/waitable_event.h"
#include "content/common/plugin_list.h"
-#include "content/public/app/content_main_runner.h"
-#include "content/public/common/main_function_params.h"
-#include "content/public/browser/browser_main_runner.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/storage_partition.h"
#include "content/public/browser/render_process_host.h"
-#include "content/public/common/content_client.h"
-#include "content/common/plugin_list.h"
-#include "content/public/app/content_main_runner.h"
-#include "content/public/common/main_function_params.h"
-#include "content/public/browser/browser_main_runner.h"
-#include "content/public/browser/utility_process_host.h"
-#include "content/utility/in_process_utility_thread.h"
-#include "content/renderer/in_process_renderer_thread.h"
-#include "content/gpu/in_process_gpu_thread.h"
-#include "content/browser/gpu/gpu_process_host.h"
-#include "content/public/common/content_switches.h"
-#include "common/render_messages_efl.h"
-#include "browser/renderer_host/browsing_data_remover_efl.h"
-#include "browser/vibration/vibration_provider_client.h"
-#include "content_main_delegate_efl.h"
-#include "message_pump_for_ui_efl.h"
-#include "API/ewk_security_origin_private.h"
-#include "web_contents_delegate_efl.h"
-#include "screen_efl.h"
-#include "memory_purger.h"
-#include "cookie_manager.h"
-#include "command_line_efl.h"
#include "net/http/http_cache.h"
-#include "net/proxy/proxy_config.h"
#include "net/proxy/proxy_config_service_fixed.h"
#include "net/proxy/proxy_service.h"
-#include "net/url_request/url_request_context_getter.h"
-#include "ui/base/resource/resource_bundle.h"
#include "webkit/browser/appcache/appcache_service.h"
#include "webkit/browser/database/database_quota_client.h"
#include "webkit/browser/fileapi/file_system_quota_client.h"
#include "webkit/browser/quota/quota_manager.h"
-#include "webkit/common/quota/quota_types.h"
-#include <Ecore.h>
+#include "browser_context_efl.h"
+#include "ewk_global_data.h"
+#include "memory_purger.h"
+#include "API/ewk_security_origin_private.h"
+#include "browser/renderer_host/browsing_data_remover_efl.h"
+#include "browser/vibration/vibration_provider_client.h"
+#include "common/render_messages_efl.h"
+
+using content::BrowserThread;
+using content::BrowserContext;
+using content::BrowserContextEfl;
-using namespace base;
-using namespace content;
using std::string;
using std::pair;
using std::map;
namespace {
-MessagePump* MessagePumpFactory() {
- return new MessagePumpForUIEfl;
-}
-
void SetProxyConfigCallbackOnIOThread(base::WaitableEvent* done,
net::URLRequestContextGetter* url_request_context_getter,
const net::ProxyConfig& proxy_config) {
(*callback_)(url.c_str(),user_data_);
}
-struct EWebContext::GlobalData {
- GlobalData()
- : content_main_runner_(ContentMainRunner::Create())
- , browser_main_runner_(BrowserMainRunner::Create()) {
- }
-
- ContentMainRunner* content_main_runner_;
- BrowserMainRunner* browser_main_runner_;
-};
-
EWebContext* EWebContext::default_context_ = NULL;
-EWebContext::GlobalData* EWebContext::global_data_ = NULL;
EWebContext* ToEWebContext(Ewk_Context* context) {
EWebContext* web_context = ewk_object_cast<EWebContext*>(context);
EWebContext::EWebContext()
: m_pixmap(0) {
- EnsureGlobalData();
+ EwkGlobalData::Ensure();
browser_context_.reset(new BrowserContextEfl(this));
// Notification Service gets init in BrowserMainRunner init,
default_context_= NULL;
}
-// static
-void EWebContext::EnsureGlobalData() {
- if (global_data_)
- return;
-
- global_data_ = new GlobalData;
-
- bool message_pump_overridden = base::MessageLoop::InitMessagePumpForUIFactory(&MessagePumpFactory);
- DCHECK(message_pump_overridden);
-
- InstallScreenInstance();
-
- global_data_->content_main_runner_->Initialize(CommandLineEfl::GetArgc(),
- CommandLineEfl::GetArgv(), new ContentMainDelegateEfl());
- global_data_->browser_main_runner_->Initialize(CommandLineEfl::GetDefaultPortParams());
-
- base::ThreadRestrictions::SetIOAllowed(true);
-
- base::FilePath pak_dir;
- base::FilePath pak_file;
- PathService::Get(base::DIR_MODULE, &pak_dir);
- pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak"));
- ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
-
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) {
- UtilityProcessHost::RegisterUtilityMainThreadFactory(
- CreateInProcessUtilityThread);
- RenderProcessHost::RegisterRendererMainThreadFactory(
- CreateInProcessRendererThread);
- GpuProcessHost::RegisterGpuMainThreadFactory(
- CreateInProcessGpuThread);
- }
-
-#ifndef NDEBUG
- logging::LoggingSettings settings;
- settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
- logging::InitLogging(settings);
- logging::SetLogItems(true, true, true, true);
-#endif
-}
-
void EWebContext::ClearNetworkCache() {
BrowsingDataRemoverEfl* remover = BrowsingDataRemoverEfl::CreateForUnboundedRange(browser_context_.get());
remover->ClearNetworkCache();
#ifndef EWEB_CONTEXT_H
#define EWEB_CONTEXT_H
-#include "base/command_line.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/run_loop.h"
-#include "content/public/app/content_main_runner.h"
-#include "content/public/browser/browser_main_runner.h"
-#include "content/public/browser/browser_context.h"
-#include "browser/renderer_host/web_cache_manager_efl.h"
#include "eweb_object.h"
#include "API/ewk_cookie_manager_private.h"
+#include "browser/renderer_host/web_cache_manager_efl.h"
#include "public/ewk_context.h"
-#include "public/ewk_ipc_message.h"
-#include "ui/gfx/rect.h"
-
-#include <Evas.h>
typedef std::map<std::string, std::string> HTTPCustomHeadersEflMap;
+class CookieManager;
+struct Ewk_IPC_Wrt_Message_Data;
+
namespace content {
class BrowserContextEfl;
}
int Pixmap() const { return m_pixmap; }
private:
- struct GlobalData;
-
virtual ~EWebContext();
- static void EnsureGlobalData();
-
static EWebContext* default_context_;
- static GlobalData* global_data_;
scoped_ptr<WebCacheManagerEfl> web_cache_manager_;
scoped_ptr<content::BrowserContextEfl> browser_context_;
HTTPCustomHeadersEflMap http_custom_headers_;
std::string proxy_uri_;
scoped_ptr<EwkDidStartDownloadCallback> start_download_callback_;
int m_pixmap;
-
- static int argc_;
- static const char** argv_;
};
EWebContext* ToEWebContext(Ewk_Context* context);
--- /dev/null
+#include "ewk_global_data.h"
+
+#include "base/logging.h"
+#include "base/path_service.h"
+#include "base/message_loop/message_loop.h"
+#include "content/browser/gpu/gpu_process_host.h"
+#include "content/gpu/in_process_gpu_thread.h"
+#include "content/public/app/content_main_runner.h"
+#include "content/public/browser/browser_main_runner.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/utility_process_host.h"
+#include "content/public/common/content_switches.h"
+#include "content/renderer/in_process_renderer_thread.h"
+#include "content/utility/in_process_utility_thread.h"
+#include "ui/base/resource/resource_bundle.h"
+
+#include "command_line_efl.h"
+#include "content_main_delegate_efl.h"
+#include "message_pump_for_ui_efl.h"
+#include "screen_efl.h"
+
+using base::MessageLoop;
+using content::BrowserMainRunner;
+using content::BrowserThread;
+using content::ContentMainDelegateEfl;
+using content::ContentMainRunner;
+using content::GpuProcessHost;
+using content::RenderProcessHost;
+using content::UtilityProcessHost;
+
+EwkGlobalData* EwkGlobalData::instance_ = NULL;
+
+namespace {
+
+base::MessagePump* MessagePumpFactory() {
+ return new base::MessagePumpForUIEfl;
+}
+
+} // namespace
+
+EwkGlobalData::EwkGlobalData()
+ : content_main_runner_(ContentMainRunner::Create())
+ , browser_main_runner_(BrowserMainRunner::Create()) {
+}
+
+EwkGlobalData::~EwkGlobalData() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ // We need to pretend that message loop was stopped so chromium unwinds correctly
+ MessageLoop *loop = MessageLoop::current();
+ loop->QuitNow();
+ // browser_main_runner must be deleted first as it depends on content_main_runner
+ delete browser_main_runner_;
+ delete content_main_runner_;
+}
+
+EwkGlobalData* EwkGlobalData::GetInstance() {
+ return instance_;
+}
+
+void EwkGlobalData::Ensure() {
+ if (instance_)
+ return;
+
+ instance_ = new EwkGlobalData();
+
+ bool message_pump_overridden = base::MessageLoop::InitMessagePumpForUIFactory(&MessagePumpFactory);
+ DCHECK(message_pump_overridden);
+
+ content::InstallScreenInstance();
+
+ instance_->content_main_runner_->Initialize(CommandLineEfl::GetArgc(),
+ CommandLineEfl::GetArgv(), new ContentMainDelegateEfl());
+ instance_->browser_main_runner_->Initialize(CommandLineEfl::GetDefaultPortParams());
+
+ base::ThreadRestrictions::SetIOAllowed(true);
+
+ base::FilePath pak_dir;
+ base::FilePath pak_file;
+ PathService::Get(base::DIR_EXE, &pak_dir);
+ pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak"));
+ ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
+
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) {
+ UtilityProcessHost::RegisterUtilityMainThreadFactory(
+ content::CreateInProcessUtilityThread);
+ RenderProcessHost::RegisterRendererMainThreadFactory(
+ content::CreateInProcessRendererThread);
+ GpuProcessHost::RegisterGpuMainThreadFactory(
+ content::CreateInProcessGpuThread);
+ }
+
+#ifndef NDEBUG
+ logging::LoggingSettings settings;
+ settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
+ logging::InitLogging(settings);
+ logging::SetLogItems(true, true, true, true);
+#endif
+}
--- /dev/null
+#ifndef EWK_GLOBAL_DATA_H_
+#define EWK_GLOBAL_DATA_H_
+
+namespace content {
+ class BrowserMainRunner;
+ class ContentMainRunner;
+}
+
+class EwkGlobalData
+{
+public:
+ ~EwkGlobalData();
+
+ static EwkGlobalData* GetInstance();
+ static void Ensure();
+
+private:
+ EwkGlobalData();
+
+private:
+ static EwkGlobalData* instance_;
+
+ content::ContentMainRunner* content_main_runner_;
+ content::BrowserMainRunner* browser_main_runner_;
+};
+
+#endif // EWK_GLOBAL_DATA_H_
}
MessagePumpForUIEfl::~MessagePumpForUIEfl() {
- DCHECK(run_loop_->running());
- run_loop_->AfterRun();
- delete run_loop_;
}
// FIXME: need to be implemented for tests.
// FIXME: need to be implemented for tests.
void MessagePumpForUIEfl::Quit() {
- NOTREACHED();
+ // RunLoop must be destroyed before chromium cleanup
+ ecore_pipe_del(pipe_);
+ DCHECK(run_loop_->running());
+ run_loop_->AfterRun();
+ delete run_loop_;
+ run_loop_ = NULL;
+ pipe_ = NULL;
}
void MessagePumpForUIEfl::ScheduleWork() {