2010-10-03 23:04:50 +02:00
|
|
|
// Copyright (c) 2010 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2010 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#include "libcef/cef_process_io_thread.h"
|
|
|
|
|
|
|
|
#include "libcef/cef_context.h"
|
|
|
|
#include "libcef/browser_appcache_system.h"
|
|
|
|
#include "libcef/browser_file_writer.h"
|
2012-04-05 00:32:24 +02:00
|
|
|
#include "libcef/browser_network_delegate.h"
|
2012-01-10 00:46:23 +01:00
|
|
|
#include "libcef/browser_resource_loader_bridge.h"
|
|
|
|
#include "libcef/browser_socket_stream_bridge.h"
|
|
|
|
#include "libcef/browser_webblobregistry_impl.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
|
|
|
|
#include "build/build_config.h"
|
2012-01-10 00:46:23 +01:00
|
|
|
#include "base/compiler_specific.h"
|
2011-05-16 18:56:12 +02:00
|
|
|
#include "net/socket/client_socket_pool_manager.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
2012-01-10 00:46:23 +01:00
|
|
|
#include <Objbase.h> // NOLINT(build/include_order)
|
2010-10-03 23:04:50 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
CefProcessIOThread::CefProcessIOThread()
|
|
|
|
: CefThread(CefThread::IO), request_context_(NULL) {}
|
|
|
|
|
|
|
|
CefProcessIOThread::CefProcessIOThread(MessageLoop* message_loop)
|
|
|
|
: CefThread(CefThread::IO, message_loop), request_context_(NULL) {}
|
|
|
|
|
|
|
|
CefProcessIOThread::~CefProcessIOThread() {
|
|
|
|
// We cannot rely on our base class to stop the thread since we want our
|
|
|
|
// CleanUp function to run.
|
|
|
|
Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefProcessIOThread::Init() {
|
2012-02-10 17:22:47 +01:00
|
|
|
CefThread::Init();
|
2011-05-16 18:56:12 +02:00
|
|
|
|
2013-02-26 00:44:37 +01:00
|
|
|
base::FilePath cache_path(_Context->cache_path());
|
2012-05-23 21:01:04 +02:00
|
|
|
request_context_.reset(new BrowserRequestContext(cache_path,
|
|
|
|
net::HttpCache::NORMAL, false));
|
|
|
|
_Context->set_request_context(request_context_.get());
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2012-04-05 00:32:24 +02:00
|
|
|
network_delegate_.reset(new BrowserNetworkDelegate());
|
|
|
|
request_context_->set_network_delegate(network_delegate_.get());
|
|
|
|
|
2012-05-23 21:01:04 +02:00
|
|
|
BrowserAppCacheSystem::InitializeOnIOThread(request_context_.get());
|
|
|
|
BrowserFileWriter::InitializeOnIOThread(request_context_.get());
|
2012-04-05 00:32:24 +02:00
|
|
|
BrowserFileSystem::InitializeOnIOThread(
|
|
|
|
request_context_->blob_storage_controller());
|
2012-05-23 21:01:04 +02:00
|
|
|
BrowserSocketStreamBridge::InitializeOnIOThread(request_context_.get());
|
2010-10-03 23:04:50 +02:00
|
|
|
BrowserWebBlobRegistryImpl::InitializeOnIOThread(
|
|
|
|
request_context_->blob_storage_controller());
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefProcessIOThread::CleanUp() {
|
|
|
|
// Flush any remaining messages. This ensures that any accumulated
|
|
|
|
// Task objects get destroyed before we exit, which avoids noise in
|
|
|
|
// purify leak-test results.
|
2013-01-15 22:38:59 +01:00
|
|
|
MessageLoop::current()->RunUntilIdle();
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2010-11-16 17:01:14 +01:00
|
|
|
// In reverse order of initialization.
|
2010-10-03 23:04:50 +02:00
|
|
|
BrowserWebBlobRegistryImpl::Cleanup();
|
2010-11-16 17:01:14 +01:00
|
|
|
BrowserSocketStreamBridge::Cleanup();
|
2012-04-05 00:32:24 +02:00
|
|
|
BrowserFileSystem::CleanupOnIOThread();
|
2010-11-16 17:01:14 +01:00
|
|
|
BrowserFileWriter::CleanupOnIOThread();
|
|
|
|
BrowserAppCacheSystem::CleanupOnIOThread();
|
2010-10-03 23:04:50 +02:00
|
|
|
|
|
|
|
_Context->set_request_context(NULL);
|
2012-04-05 00:32:24 +02:00
|
|
|
|
|
|
|
request_context_->set_network_delegate(NULL);
|
|
|
|
network_delegate_.reset(NULL);
|
|
|
|
|
2012-05-23 21:01:04 +02:00
|
|
|
_Context->set_request_context(NULL);
|
|
|
|
request_context_.reset(NULL);
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2012-02-10 17:22:47 +01:00
|
|
|
CefThread::Cleanup();
|
2010-10-03 23:04:50 +02:00
|
|
|
}
|