- Eliminate use of scoped directories (issue #670).

- Create a temporary cache_path directory if none is specified (issue #735).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@827 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2012-10-01 21:49:08 +00:00
parent 7a0ff637f0
commit 49640d17a3
8 changed files with 28 additions and 40 deletions

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "libcef/browser_database_system.h"
#include "libcef/cef_context.h"
#include "base/auto_reset.h"
#include "base/bind.h"
@ -37,9 +38,8 @@ BrowserDatabaseSystem::BrowserDatabaseSystem()
open_connections_(new webkit_database::DatabaseConnectionsWrapper) {
DCHECK(!instance_);
instance_ = this;
CHECK(temp_dir_.CreateUniqueTempDir());
db_tracker_ =
new DatabaseTracker(temp_dir_.path(), false, NULL, NULL, NULL);
new DatabaseTracker(_Context->cache_path(), false, NULL, NULL, NULL);
db_tracker_->AddObserver(this);
db_thread_.Start();
db_thread_proxy_ = db_thread_.message_loop_proxy();

View File

@ -10,7 +10,6 @@
#include "base/hash_tables.h"
#include "base/memory/ref_counted.h"
#include "base/platform_file.h"
#include "base/scoped_temp_dir.h"
#include "base/string16.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread.h"
@ -86,9 +85,6 @@ class BrowserDatabaseSystem : public webkit_database::DatabaseTracker::Observer,
void ResetTracker();
void ThreadCleanup(base::WaitableEvent* done_event);
// Where the tracker database file and per origin database files reside.
ScopedTempDir temp_dir_;
// All access to the db_tracker (except for its construction) and
// vfs operations are serialized on a background thread.
base::Thread db_thread_;

View File

@ -4,6 +4,7 @@
#include "libcef/browser_file_system.h"
#include "libcef/browser_file_writer.h"
#include "libcef/cef_context.h"
#include "libcef/cef_thread.h"
#include "base/bind.h"
@ -80,25 +81,20 @@ BrowserFileSystem::BrowserFileSystem() {
void BrowserFileSystem::CreateContext() {
if (file_system_context_.get())
return;
if (file_system_dir_.CreateUniqueTempDir()) {
std::vector<std::string> additional_allowed_schemes;
additional_allowed_schemes.push_back("file");
std::vector<std::string> additional_allowed_schemes;
additional_allowed_schemes.push_back("file");
file_system_context_ = new FileSystemContext(
make_scoped_ptr(new FileSystemTaskRunners(
CefThread::GetMessageLoopProxyForThread(CefThread::IO),
CefThread::GetMessageLoopProxyForThread(CefThread::FILE),
CefThread::GetMessageLoopProxyForThread(CefThread::FILE))),
NULL /* special storage policy */,
NULL /* quota manager */,
file_system_dir_.path(),
fileapi::FileSystemOptions(
fileapi::FileSystemOptions::PROFILE_MODE_NORMAL,
additional_allowed_schemes));
} else {
LOG(WARNING) << "Failed to create a temp dir for the filesystem."
"FileSystem feature will be disabled.";
}
file_system_context_ = new FileSystemContext(
make_scoped_ptr(new FileSystemTaskRunners(
CefThread::GetMessageLoopProxyForThread(CefThread::IO),
CefThread::GetMessageLoopProxyForThread(CefThread::FILE),
CefThread::GetMessageLoopProxyForThread(CefThread::FILE))),
NULL /* special storage policy */,
NULL /* quota manager */,
_Context->cache_path(),
fileapi::FileSystemOptions(
fileapi::FileSystemOptions::PROFILE_MODE_NORMAL,
additional_allowed_schemes));
}
BrowserFileSystem::~BrowserFileSystem() {

View File

@ -11,7 +11,6 @@
#include "base/file_util_proxy.h"
#include "base/id_map.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_temp_dir.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.h"
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_operation.h"
@ -151,9 +150,6 @@ class BrowserFileSystem
const FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
// A temporary directory for FileSystem API.
ScopedTempDir file_system_dir_;
scoped_refptr<fileapi::FileSystemContext> file_system_context_;
DISALLOW_COPY_AND_ASSIGN(BrowserFileSystem);

View File

@ -180,12 +180,6 @@ CefBrowserImpl::CefBrowserImpl(const CefWindowInfo& windowInfo,
popup_delegate_.reset(new BrowserWebViewDelegate(this));
nav_controller_.reset(new BrowserNavigationController(this));
if (!file_system_root_.CreateUniqueTempDir()) {
LOG(WARNING) << "Failed to create a temp dir for the filesystem."
"FileSystem feature will be disabled.";
DCHECK(file_system_root_.path().empty());
}
// Create the singleton main frame reference.
main_frame_ = new CefFrameImpl(this, 0, CefString(), CefString());
}

View File

@ -28,7 +28,6 @@
#include "libcef/printing/win_printing_context.h"
#endif
#include "base/scoped_temp_dir.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h"
namespace base {
@ -327,7 +326,6 @@ class CefBrowserImpl : public CefBrowser {
// These variables are read-only.
const CefBrowserSettings& settings() const { return settings_; }
const FilePath& file_system_root() const { return file_system_root_.path(); }
gfx::NativeView opener_window() { return opener_; }
bool is_popup() { return (opener_ != NULL); }
@ -429,9 +427,6 @@ class CefBrowserImpl : public CefBrowser {
// Unique browser ID assigned by the context.
int unique_id_;
// A temporary directory for FileSystem API.
ScopedTempDir file_system_root_;
IMPLEMENT_REFCOUNTING(CefBrowserImpl);
IMPLEMENT_LOCKING(CefBrowserImpl);
};

View File

@ -243,9 +243,17 @@ bool CefContext::Initialize(const CefSettings& settings,
if (!cache_path_.empty() &&
!file_util::PathExists(cache_path_) &&
!file_util::CreateDirectory(cache_path_)) {
NOTREACHED() << "Failed to create cache_path directory";
NOTREACHED() << "The cache_path directory could not be created";
cache_path_.clear();
}
if (cache_path_.empty()) {
// Create and use a temporary directory.
if (cache_temp_dir_.CreateUniqueTempDir()) {
cache_path_ = cache_temp_dir_.path();
} else {
NOTREACHED() << "Failed to create temporary cache_path directory";
}
}
#if defined(OS_MACOSX) || defined(OS_WIN)
// We want to be sure to init NSPR on the main thread.

View File

@ -19,6 +19,7 @@
#include "base/at_exit.h"
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/scoped_temp_dir.h"
#include "base/threading/sequenced_worker_pool.h"
class CefBrowserImpl;
@ -115,6 +116,8 @@ class CefContext : public CefBase {
CefSettings settings_;
CefRefPtr<CefApp> application_;
FilePath cache_path_;
ScopedTempDir cache_temp_dir_;
BrowserRequestContext* request_context_;
BrowserFileSystem file_system_;
scoped_ptr<CefResourceBundleDelegate> resource_bundle_delegate_;