Commit 20e724dd authored by Oscar Johansson's avatar Oscar Johansson Committed by Commit Bot

Remove "using base::File" to avoid conflict (net/)

When building using Jumbo namespace aliases with the same
name may end up in the same unit, causing a conflict at
compilation. This happens for base::File and
disk_cache::File in:
net/disk_cache/simple/simple_index_file.cc
net/disk_cache/simple/simple_synchronous_entry.cc

This commit removes "using base::File" and
instead call the namespace by its full
name.

Bug: 772146
Change-Id: I7385edf04bc23d519ee8800bc4941807a85340ad
Reviewed-on: https://chromium-review.googlesource.com/1120252Reviewed-by: default avatarJosh Karlin <jkarlin@chromium.org>
Commit-Queue: Oscar Johansson <oscarj@opera.com>
Cr-Commit-Position: refs/heads/master@{#571880}
parent 0248c495
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#include "net/disk_cache/simple/simple_synchronous_entry.h" #include "net/disk_cache/simple/simple_synchronous_entry.h"
#include "net/disk_cache/simple/simple_util.h" #include "net/disk_cache/simple/simple_util.h"
using base::File;
namespace disk_cache { namespace disk_cache {
namespace { namespace {
...@@ -120,9 +118,9 @@ class SimpleIndexPickle : public base::Pickle { ...@@ -120,9 +118,9 @@ class SimpleIndexPickle : public base::Pickle {
}; };
bool WritePickleFile(base::Pickle* pickle, const base::FilePath& file_name) { bool WritePickleFile(base::Pickle* pickle, const base::FilePath& file_name) {
File file( base::File file(file_name, base::File::FLAG_CREATE_ALWAYS |
file_name, base::File::FLAG_WRITE |
File::FLAG_CREATE_ALWAYS | File::FLAG_WRITE | File::FLAG_SHARE_DELETE); base::File::FLAG_SHARE_DELETE);
if (!file.IsValid()) if (!file.IsValid())
return false; return false;
...@@ -481,9 +479,10 @@ void SimpleIndexFile::SyncLoadFromDisk(const base::FilePath& index_filename, ...@@ -481,9 +479,10 @@ void SimpleIndexFile::SyncLoadFromDisk(const base::FilePath& index_filename,
SimpleIndexLoadResult* out_result) { SimpleIndexLoadResult* out_result) {
out_result->Reset(); out_result->Reset();
File file(index_filename, File::FLAG_OPEN | File::FLAG_READ | base::File file(index_filename, base::File::FLAG_OPEN |
File::FLAG_SHARE_DELETE | base::File::FLAG_READ |
File::FLAG_SEQUENTIAL_SCAN); base::File::FLAG_SHARE_DELETE |
base::File::FLAG_SEQUENTIAL_SCAN);
if (!file.IsValid()) if (!file.IsValid())
return; return;
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "net/disk_cache/simple/simple_util.h" #include "net/disk_cache/simple/simple_util.h"
#include "third_party/zlib/zlib.h" #include "third_party/zlib/zlib.h"
using base::File;
using base::FilePath; using base::FilePath;
using base::Time; using base::Time;
...@@ -88,9 +87,9 @@ bool CanOmitEmptyFile(int file_index) { ...@@ -88,9 +87,9 @@ bool CanOmitEmptyFile(int file_index) {
} }
bool TruncatePath(const FilePath& filename_to_truncate) { bool TruncatePath(const FilePath& filename_to_truncate) {
File file_to_truncate; base::File file_to_truncate;
int flags = File::FLAG_OPEN | File::FLAG_READ | File::FLAG_WRITE | int flags = base::File::FLAG_OPEN | base::File::FLAG_READ |
File::FLAG_SHARE_DELETE; base::File::FLAG_WRITE | base::File::FLAG_SHARE_DELETE;
file_to_truncate.Initialize(filename_to_truncate, flags); file_to_truncate.Initialize(filename_to_truncate, flags);
if (!file_to_truncate.IsValid()) if (!file_to_truncate.IsValid())
return false; return false;
...@@ -324,7 +323,7 @@ int SimpleSynchronousEntry::Doom() { ...@@ -324,7 +323,7 @@ int SimpleSynchronousEntry::Doom() {
for (int i = 0; i < kSimpleEntryNormalFileCount; ++i) { for (int i = 0; i < kSimpleEntryNormalFileCount; ++i) {
if (!empty_file_omitted_[i]) { if (!empty_file_omitted_[i]) {
File::Error out_error; base::File::Error out_error;
FilePath old_name = path_.AppendASCII( FilePath old_name = path_.AppendASCII(
GetFilenameFromEntryFileKeyAndFileIndex(orig_key, i)); GetFilenameFromEntryFileKeyAndFileIndex(orig_key, i));
FilePath new_name = path_.AppendASCII( FilePath new_name = path_.AppendASCII(
...@@ -334,7 +333,7 @@ int SimpleSynchronousEntry::Doom() { ...@@ -334,7 +333,7 @@ int SimpleSynchronousEntry::Doom() {
} }
if (sparse_file_open()) { if (sparse_file_open()) {
File::Error out_error; base::File::Error out_error;
FilePath old_name = FilePath old_name =
path_.AppendASCII(GetSparseFilenameFromEntryFileKey(orig_key)); path_.AppendASCII(GetSparseFilenameFromEntryFileKey(orig_key));
FilePath new_name = FilePath new_name =
...@@ -467,7 +466,7 @@ void SimpleSynchronousEntry::WriteData(const WriteRequest& in_entry_op, ...@@ -467,7 +466,7 @@ void SimpleSynchronousEntry::WriteData(const WriteRequest& in_entry_op,
out_write_result->result = net::ERR_CACHE_WRITE_FAILURE; out_write_result->result = net::ERR_CACHE_WRITE_FAILURE;
return; return;
} }
File::Error error; base::File::Error error;
if (!MaybeCreateFile(file_index, FILE_REQUIRED, &error)) { if (!MaybeCreateFile(file_index, FILE_REQUIRED, &error)) {
RecordWriteResult(cache_type_, SYNC_WRITE_RESULT_LAZY_CREATE_FAILURE); RecordWriteResult(cache_type_, SYNC_WRITE_RESULT_LAZY_CREATE_FAILURE);
Doom(); Doom();
...@@ -956,20 +955,19 @@ SimpleSynchronousEntry::~SimpleSynchronousEntry() { ...@@ -956,20 +955,19 @@ SimpleSynchronousEntry::~SimpleSynchronousEntry() {
CloseFiles(); CloseFiles();
} }
bool SimpleSynchronousEntry::MaybeOpenFile( bool SimpleSynchronousEntry::MaybeOpenFile(int file_index,
int file_index, base::File::Error* out_error) {
File::Error* out_error) {
DCHECK(out_error); DCHECK(out_error);
FilePath filename = GetFilenameFromFileIndex(file_index); FilePath filename = GetFilenameFromFileIndex(file_index);
int flags = File::FLAG_OPEN | File::FLAG_READ | File::FLAG_WRITE | int flags = base::File::FLAG_OPEN | base::File::FLAG_READ |
File::FLAG_SHARE_DELETE; base::File::FLAG_WRITE | base::File::FLAG_SHARE_DELETE;
std::unique_ptr<base::File> file = std::unique_ptr<base::File> file =
std::make_unique<base::File>(filename, flags); std::make_unique<base::File>(filename, flags);
*out_error = file->error_details(); *out_error = file->error_details();
if (CanOmitEmptyFile(file_index) && !file->IsValid() && if (CanOmitEmptyFile(file_index) && !file->IsValid() &&
*out_error == File::FILE_ERROR_NOT_FOUND) { *out_error == base::File::FILE_ERROR_NOT_FOUND) {
empty_file_omitted_[file_index] = true; empty_file_omitted_[file_index] = true;
return true; return true;
} }
...@@ -982,10 +980,9 @@ bool SimpleSynchronousEntry::MaybeOpenFile( ...@@ -982,10 +980,9 @@ bool SimpleSynchronousEntry::MaybeOpenFile(
return false; return false;
} }
bool SimpleSynchronousEntry::MaybeCreateFile( bool SimpleSynchronousEntry::MaybeCreateFile(int file_index,
int file_index, FileRequired file_required,
FileRequired file_required, base::File::Error* out_error) {
File::Error* out_error) {
DCHECK(out_error); DCHECK(out_error);
if (CanOmitEmptyFile(file_index) && file_required == FILE_NOT_REQUIRED) { if (CanOmitEmptyFile(file_index) && file_required == FILE_NOT_REQUIRED) {
...@@ -994,8 +991,8 @@ bool SimpleSynchronousEntry::MaybeCreateFile( ...@@ -994,8 +991,8 @@ bool SimpleSynchronousEntry::MaybeCreateFile(
} }
FilePath filename = GetFilenameFromFileIndex(file_index); FilePath filename = GetFilenameFromFileIndex(file_index);
int flags = File::FLAG_CREATE | File::FLAG_READ | File::FLAG_WRITE | int flags = base::File::FLAG_CREATE | base::File::FLAG_READ |
File::FLAG_SHARE_DELETE; base::File::FLAG_WRITE | base::File::FLAG_SHARE_DELETE;
std::unique_ptr<base::File> file = std::unique_ptr<base::File> file =
std::make_unique<base::File>(filename, flags); std::make_unique<base::File>(filename, flags);
...@@ -1003,7 +1000,8 @@ bool SimpleSynchronousEntry::MaybeCreateFile( ...@@ -1003,7 +1000,8 @@ bool SimpleSynchronousEntry::MaybeCreateFile(
// directory (e.g. because someone pressed "clear cache" on Android). // directory (e.g. because someone pressed "clear cache" on Android).
// If so, we would keep failing for a while until periodic index snapshot // If so, we would keep failing for a while until periodic index snapshot
// re-creates the cache dir, so try to recover from it quickly here. // re-creates the cache dir, so try to recover from it quickly here.
if (!file->IsValid() && file->error_details() == File::FILE_ERROR_NOT_FOUND && if (!file->IsValid() &&
file->error_details() == base::File::FILE_ERROR_NOT_FOUND &&
!base::DirectoryExists(path_)) { !base::DirectoryExists(path_)) {
if (base::CreateDirectory(path_)) if (base::CreateDirectory(path_))
file->Initialize(filename, flags); file->Initialize(filename, flags);
...@@ -1023,7 +1021,7 @@ bool SimpleSynchronousEntry::OpenFiles(SimpleEntryStat* out_entry_stat) { ...@@ -1023,7 +1021,7 @@ bool SimpleSynchronousEntry::OpenFiles(SimpleEntryStat* out_entry_stat) {
base::Time file_1_open_start; base::Time file_1_open_start;
for (int i = 0; i < kSimpleEntryNormalFileCount; ++i) { for (int i = 0; i < kSimpleEntryNormalFileCount; ++i) {
File::Error error; base::File::Error error;
if (i == 1) if (i == 1)
file_1_open_start = base::Time::Now(); file_1_open_start = base::Time::Now();
...@@ -1062,7 +1060,7 @@ bool SimpleSynchronousEntry::OpenFiles(SimpleEntryStat* out_entry_stat) { ...@@ -1062,7 +1060,7 @@ bool SimpleSynchronousEntry::OpenFiles(SimpleEntryStat* out_entry_stat) {
continue; continue;
} }
File::Info file_info; base::File::Info file_info;
SimpleFileTracker::FileHandle file = SimpleFileTracker::FileHandle file =
file_tracker_->Acquire(this, SubFileForFileIndex(i)); file_tracker_->Acquire(this, SubFileForFileIndex(i));
bool success = file.IsOK() && file->GetInfo(&file_info); bool success = file.IsOK() && file->GetInfo(&file_info);
...@@ -1125,7 +1123,7 @@ bool SimpleSynchronousEntry::OpenFiles(SimpleEntryStat* out_entry_stat) { ...@@ -1125,7 +1123,7 @@ bool SimpleSynchronousEntry::OpenFiles(SimpleEntryStat* out_entry_stat) {
bool SimpleSynchronousEntry::CreateFiles(SimpleEntryStat* out_entry_stat) { bool SimpleSynchronousEntry::CreateFiles(SimpleEntryStat* out_entry_stat) {
for (int i = 0; i < kSimpleEntryNormalFileCount; ++i) { for (int i = 0; i < kSimpleEntryNormalFileCount; ++i) {
File::Error error; base::File::Error error;
if (!MaybeCreateFile(i, FILE_NOT_REQUIRED, &error)) { if (!MaybeCreateFile(i, FILE_NOT_REQUIRED, &error)) {
// TODO(morlovich): Remove one each of these triplets of histograms. We // TODO(morlovich): Remove one each of these triplets of histograms. We
// can calculate the third as the sum or difference of the other two. // can calculate the third as the sum or difference of the other two.
...@@ -1622,13 +1620,13 @@ bool SimpleSynchronousEntry::OpenSparseFileIfExists( ...@@ -1622,13 +1620,13 @@ bool SimpleSynchronousEntry::OpenSparseFileIfExists(
FilePath filename = FilePath filename =
path_.AppendASCII(GetSparseFilenameFromEntryFileKey(entry_file_key_)); path_.AppendASCII(GetSparseFilenameFromEntryFileKey(entry_file_key_));
int flags = File::FLAG_OPEN | File::FLAG_READ | File::FLAG_WRITE | int flags = base::File::FLAG_OPEN | base::File::FLAG_READ |
File::FLAG_SHARE_DELETE; base::File::FLAG_WRITE | base::File::FLAG_SHARE_DELETE;
std::unique_ptr<base::File> sparse_file = std::unique_ptr<base::File> sparse_file =
std::make_unique<base::File>(filename, flags); std::make_unique<base::File>(filename, flags);
if (!sparse_file->IsValid()) if (!sparse_file->IsValid())
// No file -> OK, file open error -> trouble. // No file -> OK, file open error -> trouble.
return sparse_file->error_details() == File::FILE_ERROR_NOT_FOUND; return sparse_file->error_details() == base::File::FILE_ERROR_NOT_FOUND;
if (!ScanSparseFile(sparse_file.get(), out_sparse_data_size)) if (!ScanSparseFile(sparse_file.get(), out_sparse_data_size))
return false; return false;
...@@ -1644,8 +1642,8 @@ bool SimpleSynchronousEntry::CreateSparseFile() { ...@@ -1644,8 +1642,8 @@ bool SimpleSynchronousEntry::CreateSparseFile() {
FilePath filename = FilePath filename =
path_.AppendASCII(GetSparseFilenameFromEntryFileKey(entry_file_key_)); path_.AppendASCII(GetSparseFilenameFromEntryFileKey(entry_file_key_));
int flags = File::FLAG_CREATE | File::FLAG_READ | File::FLAG_WRITE | int flags = base::File::FLAG_CREATE | base::File::FLAG_READ |
File::FLAG_SHARE_DELETE; base::File::FLAG_WRITE | base::File::FLAG_SHARE_DELETE;
std::unique_ptr<base::File> sparse_file = std::unique_ptr<base::File> sparse_file =
std::make_unique<base::File>(filename, flags); std::make_unique<base::File>(filename, flags);
if (!sparse_file->IsValid()) if (!sparse_file->IsValid())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment