<commit_before>#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/public/app/content_main.h"
#include "content/renderer/in_process_renderer_thread.h"
#include "content/utility/in_process_utility_thread.h"
#include "content/browser/utility_process_host_impl.h"
#include "content/browser/renderer_host/render_process_host_impl.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"
#include "memory_sampler.h"

#ifdef OS_TIZEN_MOBILE
#include <dlfcn.h>
void* EflAssistHandle = 0;
#endif

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 {

scoped_ptr<base::MessagePump> MessagePumpFactory() {
  return scoped_ptr<base::MessagePump>(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();
    WebMemorySampler::shared()->stop();
    // 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();

	content::ContentMainParams params(new ContentMainDelegateEfl());
	params.argc = CommandLineEfl::GetArgc();
	params.argv = CommandLineEfl::GetArgv();

  instance_->content_main_runner_->Initialize(params);
  instance_->browser_main_runner_->Initialize(CommandLineEfl::GetDefaultPortParams());

  base::ThreadRestrictions::SetIOAllowed(true);

  base::FilePath pak_dir;
  base::FilePath pak_file;<commit_msg>Add early initilization workaround for base::CPU to avoid asserts on IO thread.<commit_after>#include "ewk_global_data.h"

#include "base/cpu.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/public/app/content_main.h"
#include "content/renderer/in_process_renderer_thread.h"
#include "content/utility/in_process_utility_thread.h"
#include "content/browser/utility_process_host_impl.h"
#include "content/browser/renderer_host/render_process_host_impl.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"
#include "memory_sampler.h"

#ifdef OS_TIZEN_MOBILE
#include <dlfcn.h>
void* EflAssistHandle = 0;
#endif

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 {

scoped_ptr<base::MessagePump> MessagePumpFactory() {
  return scoped_ptr<base::MessagePump>(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();
    WebMemorySampler::shared()->stop();
    // 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;

  // Workaround for cpu info logging asserting if executed on the wrong thread
  // during cpu info lazy instance initialization.
  base::CPU cpu;
  DCHECK(cpu.cpu_brand() != "");

  instance_ = new EwkGlobalData();

  bool message_pump_overridden =
      base::MessageLoop::InitMessagePumpForUIFactory(&MessagePumpFactory);
  DCHECK(message_pump_overridden);

  content::InstallScreenInstance();

	content::ContentMainParams params(new ContentMainDelegateEfl());
	params.argc = CommandLineEfl::GetArgc();
	params.argv = CommandLineEfl::GetArgv();

  instance_->content_main_runner_->Initialize(params);
  instance_->browser_main_runner_->Initialize(CommandLineEfl::GetDefaultPortParams());

  base::ThreadRestrictions::SetIOAllowed(true);

  base::FilePath pak_dir;
  base::FilePath pak_file;
{'fraction_non_alphanumeric': 0.11745566943224336, 'fraction_numerical': 0.00032536196518626975, 'mean_word_length': 7.29689608636977, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3675122', 'n_tokens_mistral': 2007, 'n_tokens_neox': 1986, 'n_words': 329}