summaryrefslogtreecommitdiffstats
path: root/content/browser/download
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-26 23:23:55 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-26 23:23:55 +0000
commit3586962cf6d542d53a342fb4823b36b09ba71544 (patch)
tree5463757709af4eb068c00850f91ba78c14110fa0 /content/browser/download
parent6e268e024c7a5f96f6f269f0e438490ef6c73b53 (diff)
downloadchromium_src-3586962cf6d542d53a342fb4823b36b09ba71544.zip
chromium_src-3586962cf6d542d53a342fb4823b36b09ba71544.tar.gz
chromium_src-3586962cf6d542d53a342fb4823b36b09ba71544.tar.bz2
Move download code to the content namespace.
Review URL: https://codereview.chromium.org/11320016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164439 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/download')
-rw-r--r--content/browser/download/base_file.cc69
-rw-r--r--content/browser/download/base_file.h33
-rw-r--r--content/browser/download/base_file_linux.cc8
-rw-r--r--content/browser/download/base_file_mac.cc10
-rw-r--r--content/browser/download/base_file_posix.cc8
-rw-r--r--content/browser/download/base_file_unittest.cc53
-rw-r--r--content/browser/download/base_file_win.cc72
-rw-r--r--content/browser/download/byte_stream.cc34
-rw-r--r--content/browser/download/byte_stream.h8
-rw-r--r--content/browser/download/byte_stream_unittest.cc151
-rw-r--r--content/browser/download/download_browsertest.cc23
-rw-r--r--content/browser/download/download_create_info.cc12
-rw-r--r--content/browser/download/download_create_info.h12
-rw-r--r--content/browser/download/download_file_impl.cc67
-rw-r--r--content/browser/download/download_file_impl.h24
-rw-r--r--content/browser/download/download_file_unittest.cc94
-rw-r--r--content/browser/download/download_id_unittest.cc12
-rw-r--r--content/browser/download/download_item_factory.h23
-rw-r--r--content/browser/download/download_item_impl.cc144
-rw-r--r--content/browser/download/download_item_impl.h67
-rw-r--r--content/browser/download/download_item_impl_delegate.cc10
-rw-r--r--content/browser/download/download_item_impl_delegate.h12
-rw-r--r--content/browser/download/download_item_impl_unittest.cc72
-rw-r--r--content/browser/download/download_manager_impl.cc59
-rw-r--r--content/browser/download/download_manager_impl.h65
-rw-r--r--content/browser/download/download_manager_impl_unittest.cc138
-rw-r--r--content/browser/download/download_net_log_parameters.cc84
-rw-r--r--content/browser/download/download_net_log_parameters.h76
-rw-r--r--content/browser/download/download_request_handle.cc13
-rw-r--r--content/browser/download/download_request_handle.h11
-rw-r--r--content/browser/download/download_resource_handler.cc46
-rw-r--r--content/browser/download/download_resource_handler.h33
-rw-r--r--content/browser/download/download_stats.cc6
-rw-r--r--content/browser/download/download_stats.h6
-rw-r--r--content/browser/download/drag_download_file.cc21
-rw-r--r--content/browser/download/drag_download_file.h37
-rw-r--r--content/browser/download/drag_download_util.cc5
-rw-r--r--content/browser/download/drag_download_util.h4
-rw-r--r--content/browser/download/mhtml_generation_browsertest.cc2
-rw-r--r--content/browser/download/mhtml_generation_manager.cc6
-rw-r--r--content/browser/download/mhtml_generation_manager.h5
-rw-r--r--content/browser/download/mock_download_file.cc7
-rw-r--r--content/browser/download/mock_download_file.h14
-rw-r--r--content/browser/download/save_file.cc12
-rw-r--r--content/browser/download/save_file.h10
-rw-r--r--content/browser/download/save_file_manager.cc19
-rw-r--r--content/browser/download/save_file_manager.h25
-rw-r--r--content/browser/download/save_file_resource_handler.cc8
-rw-r--r--content/browser/download/save_file_resource_handler.h9
-rw-r--r--content/browser/download/save_item.cc6
-rw-r--r--content/browser/download/save_item.h9
-rw-r--r--content/browser/download/save_package.cc97
-rw-r--r--content/browser/download/save_package.h45
-rw-r--r--content/browser/download/save_package_unittest.cc6
-rw-r--r--content/browser/download/save_types.cc3
-rw-r--r--content/browser/download/save_types.h3
56 files changed, 935 insertions, 973 deletions
diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc
index 65fd7a1..7207e1d 100644
--- a/content/browser/download/base_file.cc
+++ b/content/browser/download/base_file.cc
@@ -20,7 +20,7 @@
#include "net/base/file_stream.h"
#include "net/base/net_errors.h"
-using content::BrowserThread;
+namespace content {
// This will initialize the entire array to zero.
const unsigned char BaseFile::kEmptySha256Hash[] = { 0 };
@@ -62,7 +62,7 @@ BaseFile::~BaseFile() {
Cancel(); // Will delete the file.
}
-content::DownloadInterruptReason BaseFile::Initialize(
+DownloadInterruptReason BaseFile::Initialize(
const FilePath& default_directory) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK(!detached_);
@@ -77,7 +77,7 @@ content::DownloadInterruptReason BaseFile::Initialize(
FilePath temp_file;
if (initial_directory.empty()) {
initial_directory =
- content::GetContentClient()->browser()->GetDefaultDownloadDirectory();
+ GetContentClient()->browser()->GetDefaultDownloadDirectory();
}
// |initial_directory| can still be empty if ContentBrowserClient returned
// an empty path for the downloads directory.
@@ -85,7 +85,7 @@ content::DownloadInterruptReason BaseFile::Initialize(
!file_util::CreateTemporaryFileInDir(initial_directory, &temp_file)) &&
!file_util::CreateTemporaryFile(&temp_file)) {
return LogInterruptReason("Unable to create", 0,
- content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED);
+ DOWNLOAD_INTERRUPT_REASON_FILE_FAILED);
}
full_path_ = temp_file;
}
@@ -93,25 +93,23 @@ content::DownloadInterruptReason BaseFile::Initialize(
return Open();
}
-content::DownloadInterruptReason BaseFile::AppendDataToFile(const char* data,
- size_t data_len) {
+DownloadInterruptReason BaseFile::AppendDataToFile(const char* data,
+ size_t data_len) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK(!detached_);
// NOTE(benwells): The above DCHECK won't be present in release builds,
// so we log any occurences to see how common this error is in the wild.
- if (detached_) {
- download_stats::RecordDownloadCount(
- download_stats::APPEND_TO_DETACHED_FILE_COUNT);
- }
+ if (detached_)
+ RecordDownloadCount(APPEND_TO_DETACHED_FILE_COUNT);
if (!file_stream_.get())
return LogInterruptReason("No file stream on append", 0,
- content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED);
+ DOWNLOAD_INTERRUPT_REASON_FILE_FAILED);
// TODO(phajdan.jr): get rid of this check.
if (data_len == 0)
- return content::DOWNLOAD_INTERRUPT_REASON_NONE;
+ return DOWNLOAD_INTERRUPT_REASON_NONE;
// The Write call below is not guaranteed to write all the data.
size_t write_count = 0;
@@ -141,24 +139,23 @@ content::DownloadInterruptReason BaseFile::AppendDataToFile(const char* data,
bytes_so_far_ += write_size;
}
- download_stats::RecordDownloadWriteSize(data_len);
- download_stats::RecordDownloadWriteLoopCount(write_count);
+ RecordDownloadWriteSize(data_len);
+ RecordDownloadWriteLoopCount(write_count);
if (calculate_hash_)
secure_hash_->Update(data, data_len);
- return content::DOWNLOAD_INTERRUPT_REASON_NONE;
+ return DOWNLOAD_INTERRUPT_REASON_NONE;
}
-content::DownloadInterruptReason BaseFile::Rename(const FilePath& new_path) {
+DownloadInterruptReason BaseFile::Rename(const FilePath& new_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- content::DownloadInterruptReason rename_result =
- content::DOWNLOAD_INTERRUPT_REASON_NONE;
+ DownloadInterruptReason rename_result = DOWNLOAD_INTERRUPT_REASON_NONE;
// If the new path is same as the old one, there is no need to perform the
// following renaming logic.
if (new_path == full_path_)
- return content::DOWNLOAD_INTERRUPT_REASON_NONE;
+ return DOWNLOAD_INTERRUPT_REASON_NONE;
// Save the information whether the download is in progress because
// it will be overwritten by closing the file.
@@ -166,8 +163,7 @@ content::DownloadInterruptReason BaseFile::Rename(const FilePath& new_path) {
bound_net_log_.BeginEvent(
net::NetLog::TYPE_DOWNLOAD_FILE_RENAMED,
- base::Bind(&download_net_logs::FileRenamedCallback,
- &full_path_, &new_path));
+ base::Bind(&FileRenamedNetLogCallback, &full_path_, &new_path));
Close();
file_util::CreateDirectory(new_path.DirName());
@@ -175,7 +171,7 @@ content::DownloadInterruptReason BaseFile::Rename(const FilePath& new_path) {
// permissions / security descriptors that makes sense in the new directory.
rename_result = MoveFileAndAdjustPermissions(new_path);
- if (rename_result == content::DOWNLOAD_INTERRUPT_REASON_NONE) {
+ if (rename_result == DOWNLOAD_INTERRUPT_REASON_NONE) {
full_path_ = new_path;
// Re-open the file if we were still using it.
if (was_in_progress)
@@ -267,15 +263,14 @@ void BaseFile::CreateFileStream() {
file_stream_->SetBoundNetLogSource(bound_net_log_);
}
-content::DownloadInterruptReason BaseFile::Open() {
+DownloadInterruptReason BaseFile::Open() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK(!detached_);
DCHECK(!full_path_.empty());
bound_net_log_.BeginEvent(
net::NetLog::TYPE_DOWNLOAD_FILE_OPENED,
- base::Bind(&download_net_logs::FileOpenedCallback,
- &full_path_, bytes_so_far_));
+ base::Bind(&FileOpenedNetLogCallback, &full_path_, bytes_so_far_));
// Create a new file stream if it is not provided.
if (!file_stream_.get()) {
@@ -300,7 +295,7 @@ content::DownloadInterruptReason BaseFile::Open() {
file_stream_->SetBoundNetLogSource(bound_net_log_);
}
- return content::DOWNLOAD_INTERRUPT_REASON_NONE;
+ return DOWNLOAD_INTERRUPT_REASON_NONE;
}
void BaseFile::Close() {
@@ -332,34 +327,34 @@ int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const {
return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms;
}
-content::DownloadInterruptReason BaseFile::LogNetError(
+DownloadInterruptReason BaseFile::LogNetError(
const char* operation,
net::Error error) {
bound_net_log_.AddEvent(
net::NetLog::TYPE_DOWNLOAD_FILE_ERROR,
- base::Bind(&download_net_logs::FileErrorCallback, operation, error));
- return content::ConvertNetErrorToInterruptReason(
- error, content::DOWNLOAD_INTERRUPT_FROM_DISK);
+ base::Bind(&FileErrorNetLogCallback, operation, error));
+ return ConvertNetErrorToInterruptReason(error, DOWNLOAD_INTERRUPT_FROM_DISK);
}
-content::DownloadInterruptReason BaseFile::LogSystemError(
+DownloadInterruptReason BaseFile::LogSystemError(
const char* operation,
int os_error) {
// There's no direct conversion from a system error to an interrupt reason.
net::Error net_error = net::MapSystemError(os_error);
return LogInterruptReason(
operation, os_error,
- content::ConvertNetErrorToInterruptReason(
- net_error, content::DOWNLOAD_INTERRUPT_FROM_DISK));
+ ConvertNetErrorToInterruptReason(
+ net_error, DOWNLOAD_INTERRUPT_FROM_DISK));
}
-content::DownloadInterruptReason BaseFile::LogInterruptReason(
+DownloadInterruptReason BaseFile::LogInterruptReason(
const char* operation,
int os_error,
- content::DownloadInterruptReason reason) {
+ DownloadInterruptReason reason) {
bound_net_log_.AddEvent(
net::NetLog::TYPE_DOWNLOAD_FILE_ERROR,
- base::Bind(&download_net_logs::FileInterruptedCallback, operation,
- os_error, reason));
+ base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason));
return reason;
}
+
+} // namespace content
diff --git a/content/browser/download/base_file.h b/content/browser/download/base_file.h
index e6ae0a3..d8bfecc 100644
--- a/content/browser/download/base_file.h
+++ b/content/browser/download/base_file.h
@@ -19,9 +19,6 @@
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
-namespace content {
-enum DownloadInterruptReason;
-}
namespace crypto {
class SecureHash;
}
@@ -29,6 +26,8 @@ namespace net {
class FileStream;
}
+namespace content {
+
// File being downloaded and saved to disk. This is a base class
// for DownloadFile and SaveFile, which keep more state information.
class CONTENT_EXPORT BaseFile {
@@ -51,17 +50,15 @@ class CONTENT_EXPORT BaseFile {
// |default_directory| and |full_path()| are empty, then a temporary file will
// be created in the default download location as determined by
// ContentBrowserClient.
- content::DownloadInterruptReason Initialize(
- const FilePath& default_directory);
+ DownloadInterruptReason Initialize(const FilePath& default_directory);
// Write a new chunk of data to the file. Returns a DownloadInterruptReason
// indicating the result of the operation.
- content::DownloadInterruptReason AppendDataToFile(const char* data,
- size_t data_len);
+ DownloadInterruptReason AppendDataToFile(const char* data, size_t data_len);
// Rename the download file. Returns a DownloadInterruptReason indicating the
// result of the operation.
- virtual content::DownloadInterruptReason Rename(const FilePath& full_path);
+ virtual DownloadInterruptReason Rename(const FilePath& full_path);
// Detach the file so it is not deleted on destruction.
virtual void Detach();
@@ -104,7 +101,7 @@ class CONTENT_EXPORT BaseFile {
void CreateFileStream();
// Creates and opens the file_stream_ if it is NULL.
- content::DownloadInterruptReason Open();
+ DownloadInterruptReason Open();
// Closes and resets file_stream_.
void Close();
@@ -115,27 +112,25 @@ class CONTENT_EXPORT BaseFile {
// Platform specific method that moves a file to a new path and adjusts the
// security descriptor / permissions on the file to match the defaults for the
// new directory.
- content::DownloadInterruptReason MoveFileAndAdjustPermissions(
+ DownloadInterruptReason MoveFileAndAdjustPermissions(
const FilePath& new_path);
// Split out from CurrentSpeed to enable testing.
int64 CurrentSpeedAtTime(base::TimeTicks current_time) const;
// Log a TYPE_DOWNLOAD_FILE_ERROR NetLog event with |error| and passes error
- // on through, converting to a |content::DownloadInterruptReason|.
- content::DownloadInterruptReason LogNetError(
- const char* operation, net::Error error);
+ // on through, converting to a |DownloadInterruptReason|.
+ DownloadInterruptReason LogNetError(const char* operation, net::Error error);
// Log the system error in |os_error| and converts it into a
- // |content::DownloadInterruptReason|.
- content::DownloadInterruptReason LogSystemError(
- const char* operation, int os_error);
+ // |DownloadInterruptReason|.
+ DownloadInterruptReason LogSystemError(const char* operation, int os_error);
// Log a TYPE_DOWNLOAD_FILE_ERROR NetLog event with |os_error| and |reason|.
// Returns |reason|.
- content::DownloadInterruptReason LogInterruptReason(
+ DownloadInterruptReason LogInterruptReason(
const char* operation, int os_error,
- content::DownloadInterruptReason reason);
+ DownloadInterruptReason reason);
static const size_t kSha256HashLen = 32;
static const unsigned char kEmptySha256Hash[kSha256HashLen];
@@ -176,4 +171,6 @@ class CONTENT_EXPORT BaseFile {
DISALLOW_COPY_AND_ASSIGN(BaseFile);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_
diff --git a/content/browser/download/base_file_linux.cc b/content/browser/download/base_file_linux.cc
index 7f8b717..07215b0 100644
--- a/content/browser/download/base_file_linux.cc
+++ b/content/browser/download/base_file_linux.cc
@@ -7,9 +7,13 @@
#include "content/browser/download/file_metadata_linux.h"
#include "content/public/browser/browser_thread.h"
+namespace content {
+
void BaseFile::AnnotateWithSourceInformation() {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK(!detached_);
- content::AddOriginMetadataToFile(full_path_, source_url_, referrer_url_);
+ AddOriginMetadataToFile(full_path_, source_url_, referrer_url_);
}
+
+} // namespace content
diff --git a/content/browser/download/base_file_mac.cc b/content/browser/download/base_file_mac.cc
index 88ad5f0..e3ce2d7 100644
--- a/content/browser/download/base_file_mac.cc
+++ b/content/browser/download/base_file_mac.cc
@@ -7,10 +7,14 @@
#include "content/browser/download/file_metadata_mac.h"
#include "content/public/browser/browser_thread.h"
+namespace content {
+
void BaseFile::AnnotateWithSourceInformation() {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK(!detached_);
- content::AddQuarantineMetadataToFile(full_path_, source_url_, referrer_url_);
- content::AddOriginMetadataToFile(full_path_, source_url_, referrer_url_);
+ AddQuarantineMetadataToFile(full_path_, source_url_, referrer_url_);
+ AddOriginMetadataToFile(full_path_, source_url_, referrer_url_);
}
+
+} // namespace content
diff --git a/content/browser/download/base_file_posix.cc b/content/browser/download/base_file_posix.cc
index b5538bf..da654d0 100644
--- a/content/browser/download/base_file_posix.cc
+++ b/content/browser/download/base_file_posix.cc
@@ -7,7 +7,9 @@
#include "base/file_util.h"
#include "content/public/browser/download_interrupt_reasons.h"
-content::DownloadInterruptReason BaseFile::MoveFileAndAdjustPermissions(
+namespace content {
+
+DownloadInterruptReason BaseFile::MoveFileAndAdjustPermissions(
const FilePath& new_path) {
// Similarly, on Unix, we're moving a temp file created with permissions 600
// to |new_path|. Here, we try to fix up the destination file with appropriate
@@ -36,5 +38,7 @@ content::DownloadInterruptReason BaseFile::MoveFileAndAdjustPermissions(
if (chmod_error < 0)
LogSystemError("chmod", errno);
}
- return content::DOWNLOAD_INTERRUPT_REASON_NONE;
+ return DOWNLOAD_INTERRUPT_REASON_NONE;
}
+
+} // namespace content
diff --git a/content/browser/download/base_file_unittest.cc b/content/browser/download/base_file_unittest.cc
index e672fbb..c8d24b2 100644
--- a/content/browser/download/base_file_unittest.cc
+++ b/content/browser/download/base_file_unittest.cc
@@ -17,9 +17,7 @@
#include "net/base/mock_file_stream.h"
#include "testing/gtest/include/gtest/gtest.h"
-using content::BrowserThread;
-using content::BrowserThreadImpl;
-
+namespace content {
namespace {
const char kTestData1[] = "Let's write some data to the file!\n";
@@ -44,7 +42,7 @@ class BaseFileTest : public testing::Test {
BaseFileTest()
: expect_file_survives_(false),
expect_in_progress_(true),
- expected_error_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
+ expected_error_(DOWNLOAD_INTERRUPT_REASON_NONE),
file_thread_(BrowserThread::FILE, &message_loop_) {
}
@@ -113,28 +111,27 @@ class BaseFileTest : public testing::Test {
}
bool InitializeFile() {
- content::DownloadInterruptReason result =
- base_file_->Initialize(temp_dir_.path());
+ DownloadInterruptReason result = base_file_->Initialize(temp_dir_.path());
EXPECT_EQ(expected_error_, result);
- return result == content::DOWNLOAD_INTERRUPT_REASON_NONE;
+ return result == DOWNLOAD_INTERRUPT_REASON_NONE;
}
bool AppendDataToFile(const std::string& data) {
EXPECT_EQ(expect_in_progress_, base_file_->in_progress());
- content::DownloadInterruptReason result =
+ DownloadInterruptReason result =
base_file_->AppendDataToFile(data.data(), data.size());
- if (result == content::DOWNLOAD_INTERRUPT_REASON_NONE)
+ if (result == DOWNLOAD_INTERRUPT_REASON_NONE)
EXPECT_TRUE(expect_in_progress_) << " result = " << result;
EXPECT_EQ(expected_error_, result);
if (base_file_->in_progress()) {
expected_data_ += data;
- if (expected_error_ == content::DOWNLOAD_INTERRUPT_REASON_NONE) {
+ if (expected_error_ == DOWNLOAD_INTERRUPT_REASON_NONE) {
EXPECT_EQ(static_cast<int64>(expected_data_.size()),
base_file_->bytes_so_far());
}
}
- return result == content::DOWNLOAD_INTERRUPT_REASON_NONE;
+ return result == DOWNLOAD_INTERRUPT_REASON_NONE;
}
void set_expected_data(const std::string& data) { expected_data_ = data; }
@@ -152,12 +149,12 @@ class BaseFileTest : public testing::Test {
scoped_ptr<net::FileStream>(),
net::BoundNetLog());
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
file.Initialize(temp_dir_.path()));
file_name = file.full_path();
EXPECT_NE(FilePath::StringType(), file_name.value());
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
file.AppendDataToFile(kTestData4, kTestDataLength4));
// Keep the file from getting deleted when existing_file_name is deleted.
@@ -177,7 +174,7 @@ class BaseFileTest : public testing::Test {
"",
scoped_ptr<net::FileStream>(),
net::BoundNetLog());
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
duplicate_file.Initialize(temp_dir_.path()));
// Write something into it.
duplicate_file.AppendDataToFile(kTestData4, kTestDataLength4);
@@ -195,7 +192,7 @@ class BaseFileTest : public testing::Test {
return base_file_->start_tick_;
}
- void set_expected_error(content::DownloadInterruptReason err) {
+ void set_expected_error(DownloadInterruptReason err) {
expected_error_ = err;
}
@@ -222,7 +219,7 @@ class BaseFileTest : public testing::Test {
private:
// Keep track of what data should be saved to the disk file.
std::string expected_data_;
- content::DownloadInterruptReason expected_error_;
+ DownloadInterruptReason expected_error_;
// Mock file thread to satisfy debug checks in BaseFile.
MessageLoop message_loop_;
@@ -293,8 +290,7 @@ TEST_F(BaseFileTest, WriteThenRenameAndDetach) {
ASSERT_TRUE(AppendDataToFile(kTestData1));
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
- base_file_->Rename(new_path));
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE, base_file_->Rename(new_path));
EXPECT_FALSE(file_util::PathExists(initial_path));
EXPECT_TRUE(file_util::PathExists(new_path));
@@ -402,10 +398,10 @@ TEST_F(BaseFileTest, MultipleWritesInterruptedWithHash) {
hash_state,
scoped_ptr<net::FileStream>(),
net::BoundNetLog());
- ASSERT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ ASSERT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
second_file.Initialize(temp_dir_.path()));
std::string data(kTestData3);
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
second_file.AppendDataToFile(data.data(), data.size()));
second_file.Finish();
@@ -427,7 +423,7 @@ TEST_F(BaseFileTest, WriteThenRename) {
ASSERT_TRUE(AppendDataToFile(kTestData1));
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
base_file_->Rename(new_path));
EXPECT_FALSE(file_util::PathExists(initial_path));
EXPECT_TRUE(file_util::PathExists(new_path));
@@ -447,8 +443,7 @@ TEST_F(BaseFileTest, RenameWhileInProgress) {
ASSERT_TRUE(AppendDataToFile(kTestData1));
EXPECT_TRUE(base_file_->in_progress());
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
- base_file_->Rename(new_path));
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE, base_file_->Rename(new_path));
EXPECT_FALSE(file_util::PathExists(initial_path));
EXPECT_TRUE(file_util::PathExists(new_path));
@@ -472,7 +467,7 @@ TEST_F(BaseFileTest, RenameWithError) {
{
file_util::PermissionRestorer restore_permissions_for(test_dir);
ASSERT_TRUE(file_util::MakeFileUnwritable(test_dir));
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED,
base_file_->Rename(new_path));
}
@@ -510,7 +505,7 @@ TEST_F(BaseFileTest, MultipleWritesWithError) {
ASSERT_TRUE(AppendDataToFile(kTestData1));
ASSERT_TRUE(AppendDataToFile(kTestData2));
mock_file_stream->set_forced_error(net::ERR_ACCESS_DENIED);
- set_expected_error(content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED);
+ set_expected_error(DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED);
ASSERT_FALSE(AppendDataToFile(kTestData3));
std::string hash;
EXPECT_FALSE(base_file_->GetHash(&hash));
@@ -520,7 +515,7 @@ TEST_F(BaseFileTest, MultipleWritesWithError) {
// Try to write to uninitialized file.
TEST_F(BaseFileTest, UninitializedFile) {
expect_in_progress_ = false;
- set_expected_error(content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED);
+ set_expected_error(DOWNLOAD_INTERRUPT_REASON_FILE_FAILED);
EXPECT_FALSE(AppendDataToFile(kTestData1));
}
@@ -589,14 +584,14 @@ TEST_F(BaseFileTest, ReadonlyBaseFile) {
net::BoundNetLog()));
expect_in_progress_ = false;
- set_expected_error(content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED);
+ set_expected_error(DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED);
EXPECT_FALSE(InitializeFile());
const FilePath file_name = base_file_->full_path();
EXPECT_NE(FilePath::StringType(), file_name.value());
// Write into the file.
- set_expected_error(content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED);
+ set_expected_error(DOWNLOAD_INTERRUPT_REASON_FILE_FAILED);
EXPECT_FALSE(AppendDataToFile(kTestData1));
base_file_->Finish();
@@ -670,3 +665,5 @@ TEST_F(BaseFileTest, CreatedInDefaultDirectory) {
base_file_->full_path().DirName().value().c_str());
base_file_->Finish();
}
+
+} // namespace content
diff --git a/content/browser/download/base_file_win.cc b/content/browser/download/base_file_win.cc
index b3b7e18..a98597d 100644
--- a/content/browser/download/base_file_win.cc
+++ b/content/browser/download/base_file_win.cc
@@ -13,132 +13,133 @@
#include "content/browser/safe_util_win.h"
#include "content/public/browser/browser_thread.h"
+namespace content {
namespace {
// Maps the result of a call to |SHFileOperation()| onto a
-// |content::DownloadInterruptReason|.
+// |DownloadInterruptReason|.
//
// These return codes are *old* (as in, DOS era), and specific to
// |SHFileOperation()|.
// They do not appear in any windows header.
//
// See http://msdn.microsoft.com/en-us/library/bb762164(VS.85).aspx.
-content::DownloadInterruptReason MapShFileOperationCodes(int code) {
+DownloadInterruptReason MapShFileOperationCodes(int code) {
// Check these pre-Win32 error codes first, then check for matches
// in Winerror.h.
switch (code) {
// The source and destination files are the same file.
// DE_SAMEFILE == 0x71
- case 0x71: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x71: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
// The operation was canceled by the user, or silently canceled if the
// appropriate flags were supplied to SHFileOperation.
// DE_OPCANCELLED == 0x75
- case 0x75: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x75: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
// Security settings denied access to the source.
// DE_ACCESSDENIEDSRC == 0x78
- case 0x78: return content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
+ case 0x78: return DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
// The source or destination path exceeded or would exceed MAX_PATH.
// DE_PATHTOODEEP == 0x79
- case 0x79: return content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG;
+ case 0x79: return DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG;
// The path in the source or destination or both was invalid.
// DE_INVALIDFILES == 0x7C
- case 0x7C: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x7C: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
// The destination path is an existing file.
// DE_FLDDESTISFILE == 0x7E
- case 0x7E: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x7E: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
// The destination path is an existing folder.
// DE_FILEDESTISFLD == 0x80
- case 0x80: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x80: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
// The name of the file exceeds MAX_PATH.
// DE_FILENAMETOOLONG == 0x81
- case 0x81: return content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG;
+ case 0x81: return DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG;
// The destination is a read-only CD-ROM, possibly unformatted.
// DE_DEST_IS_CDROM == 0x82
- case 0x82: return content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
+ case 0x82: return DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
// The destination is a read-only DVD, possibly unformatted.
// DE_DEST_IS_DVD == 0x83
- case 0x83: return content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
+ case 0x83: return DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
// The destination is a writable CD-ROM, possibly unformatted.
// DE_DEST_IS_CDRECORD == 0x84
- case 0x84: return content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
+ case 0x84: return DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
// The file involved in the operation is too large for the destination
// media or file system.
// DE_FILE_TOO_LARGE == 0x85
- case 0x85: return content::DOWNLOAD_INTERRUPT_REASON_FILE_TOO_LARGE;
+ case 0x85: return DOWNLOAD_INTERRUPT_REASON_FILE_TOO_LARGE;
// The source is a read-only CD-ROM, possibly unformatted.
// DE_SRC_IS_CDROM == 0x86
- case 0x86: return content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
+ case 0x86: return DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
// The source is a read-only DVD, possibly unformatted.
// DE_SRC_IS_DVD == 0x87
- case 0x87: return content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
+ case 0x87: return DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
// The source is a writable CD-ROM, possibly unformatted.
// DE_SRC_IS_CDRECORD == 0x88
- case 0x88: return content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
+ case 0x88: return DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
// MAX_PATH was exceeded during the operation.
// DE_ERROR_MAX == 0xB7
- case 0xB7: return content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG;
+ case 0xB7: return DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG;
// An unspecified error occurred on the destination.
// XE_ERRORONDEST == 0x10000
- case 0x10000: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x10000: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
// Multiple file paths were specified in the source buffer, but only one
// destination file path.
// DE_MANYSRC1DEST == 0x72
- case 0x72: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x72: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
// Rename operation was specified but the destination path is
// a different directory. Use the move operation instead.
// DE_DIFFDIR == 0x73
- case 0x73: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x73: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
// The source is a root directory, which cannot be moved or renamed.
// DE_ROOTDIR == 0x74
- case 0x74: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x74: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
// The destination is a subtree of the source.
// DE_DESTSUBTREE == 0x76
- case 0x76: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x76: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
// The operation involved multiple destination paths,
// which can fail in the case of a move operation.
// DE_MANYDEST == 0x7A
- case 0x7A: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x7A: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
// The source and destination have the same parent folder.
// DE_DESTSAMETREE == 0x7D
- case 0x7D: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x7D: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
// An unknown error occurred. This is typically due to an invalid path in
// the source or destination. This error does not occur on Windows Vista
// and later.
// DE_UNKNOWN_ERROR == 0x402
- case 0x402: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x402: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
// Destination is a root directory and cannot be renamed.
// DE_ROOTDIR | ERRORONDEST == 0x10074
- case 0x10074: return content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ case 0x10074: return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
}
// If not one of the above codes, it should be a standard Windows error code.
- return content::ConvertNetErrorToInterruptReason(
- net::MapSystemError(code), content::DOWNLOAD_INTERRUPT_FROM_DISK);
+ return ConvertNetErrorToInterruptReason(
+ net::MapSystemError(code), DOWNLOAD_INTERRUPT_FROM_DISK);
}
} // namespace
@@ -146,7 +147,7 @@ content::DownloadInterruptReason MapShFileOperationCodes(int code) {
// Renames a file using the SHFileOperation API to ensure that the target file
// gets the correct default security descriptor in the new path.
// Returns a network error, or net::OK for success.
-content::DownloadInterruptReason BaseFile::MoveFileAndAdjustPermissions(
+DownloadInterruptReason BaseFile::MoveFileAndAdjustPermissions(
const FilePath& new_path) {
base::ThreadRestrictions::AssertIOAllowed();
@@ -165,21 +166,20 @@ content::DownloadInterruptReason BaseFile::MoveFileAndAdjustPermissions(
FOF_NOCONFIRMMKDIR | FOF_NOCOPYSECURITYATTRIBS;
int result = SHFileOperation(&move_info);
- content::DownloadInterruptReason interrupt_reason =
- content::DOWNLOAD_INTERRUPT_REASON_NONE;
+ DownloadInterruptReason interrupt_reason = DOWNLOAD_INTERRUPT_REASON_NONE;
if (result == 0 && move_info.fAnyOperationsAborted)
- interrupt_reason = content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
+ interrupt_reason = DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
else if (result != 0)
interrupt_reason = MapShFileOperationCodes(result);
- if (interrupt_reason != content::DOWNLOAD_INTERRUPT_REASON_NONE)
+ if (interrupt_reason != DOWNLOAD_INTERRUPT_REASON_NONE)
return LogInterruptReason("SHFileOperation", result, interrupt_reason);
return interrupt_reason;
}
void BaseFile::AnnotateWithSourceInformation() {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK(!detached_);
// Sets the Zone to tell Windows that this file comes from the internet.
@@ -187,3 +187,5 @@ void BaseFile::AnnotateWithSourceInformation() {
win_util::SetInternetZoneIdentifier(full_path_,
UTF8ToWide(source_url_.spec()));
}
+
+} // namespace content
diff --git a/content/browser/download/byte_stream.cc b/content/browser/download/byte_stream.cc
index 8a1e097..45f6fa0 100644
--- a/content/browser/download/byte_stream.cc
+++ b/content/browser/download/byte_stream.cc
@@ -10,6 +10,7 @@
#include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h"
+namespace content {
namespace {
typedef std::deque<std::pair<scoped_refptr<net::IOBuffer>, size_t> >
@@ -47,7 +48,7 @@ struct LifetimeFlag : public base::RefCountedThreadSafe<LifetimeFlag> {
// For both ByteStreamWriterImpl and ByteStreamReaderImpl, Construction and
// SetPeer may happen anywhere; all other operations on each class must
// happen in the context of their SequencedTaskRunner.
-class ByteStreamWriterImpl : public content::ByteStreamWriter {
+class ByteStreamWriterImpl : public ByteStreamWriter {
public:
ByteStreamWriterImpl(scoped_refptr<base::SequencedTaskRunner> task_runner,
scoped_refptr<LifetimeFlag> lifetime_flag,
@@ -62,7 +63,7 @@ class ByteStreamWriterImpl : public content::ByteStreamWriter {
// Overridden from ByteStreamWriter.
virtual bool Write(scoped_refptr<net::IOBuffer> buffer,
size_t byte_count) OVERRIDE;
- virtual void Close(content::DownloadInterruptReason status) OVERRIDE;
+ virtual void Close(DownloadInterruptReason status) OVERRIDE;
virtual void RegisterCallback(const base::Closure& source_callback) OVERRIDE;
// PostTask target from |ByteStreamReaderImpl::MaybeUpdateInput|.
@@ -74,7 +75,7 @@ class ByteStreamWriterImpl : public content::ByteStreamWriter {
// Called from UpdateWindow when object existence has been validated.
void UpdateWindowInternal(size_t bytes_consumed);
- void PostToPeer(bool complete, content::DownloadInterruptReason status);
+ void PostToPeer(bool complete, DownloadInterruptReason status);
const size_t total_buffer_size_;
@@ -105,7 +106,7 @@ class ByteStreamWriterImpl : public content::ByteStreamWriter {
ByteStreamReaderImpl* peer_;
};
-class ByteStreamReaderImpl : public content::ByteStreamReader {
+class ByteStreamReaderImpl : public ByteStreamReader {
public:
ByteStreamReaderImpl(scoped_refptr<base::SequencedTaskRunner> task_runner,
scoped_refptr<LifetimeFlag> lifetime_flag,
@@ -120,7 +121,7 @@ class ByteStreamReaderImpl : public content::ByteStreamReader {
// Overridden from ByteStreamReader.
virtual StreamState Read(scoped_refptr<net::IOBuffer>* data,
size_t* length) OVERRIDE;
- virtual content::DownloadInterruptReason GetStatus() const OVERRIDE;
+ virtual DownloadInterruptReason GetStatus() const OVERRIDE;
virtual void RegisterCallback(const base::Closure& sink_callback) OVERRIDE;
// PostTask target from |ByteStreamWriterImpl::MaybePostToPeer| and
@@ -135,7 +136,7 @@ class ByteStreamReaderImpl : public content::ByteStreamReader {
scoped_ptr<ContentVector> transfer_buffer,
size_t transfer_buffer_bytes,
bool source_complete,
- content::DownloadInterruptReason status);
+ DownloadInterruptReason status);
private:
// Called from TransferData once object existence has been validated.
@@ -143,7 +144,7 @@ class ByteStreamReaderImpl : public content::ByteStreamReader {
scoped_ptr<ContentVector> transfer_buffer,
size_t transfer_buffer_bytes,
bool source_complete,
- content::DownloadInterruptReason status);
+ DownloadInterruptReason status);
void MaybeUpdateInput();
@@ -157,7 +158,7 @@ class ByteStreamReaderImpl : public content::ByteStreamReader {
ContentVector available_contents_;
bool received_status_;
- content::DownloadInterruptReason status_;
+ DownloadInterruptReason status_;
base::Closure data_available_callback_;
@@ -217,13 +218,13 @@ bool ByteStreamWriterImpl::Write(
// Arbitrarily, we buffer to a third of the total size before sending.
if (input_contents_size_ > total_buffer_size_ / kFractionBufferBeforeSending)
- PostToPeer(false, content::DOWNLOAD_INTERRUPT_REASON_NONE);
+ PostToPeer(false, DOWNLOAD_INTERRUPT_REASON_NONE);
return (input_contents_size_ + output_size_used_ <= total_buffer_size_);
}
void ByteStreamWriterImpl::Close(
- content::DownloadInterruptReason status) {
+ DownloadInterruptReason status) {
DCHECK(my_task_runner_->RunsTasksOnCurrentThread());
PostToPeer(true, status);
}
@@ -260,7 +261,7 @@ void ByteStreamWriterImpl::UpdateWindowInternal(size_t bytes_consumed) {
}
void ByteStreamWriterImpl::PostToPeer(
- bool complete, content::DownloadInterruptReason status) {
+ bool complete, DownloadInterruptReason status) {
DCHECK(my_task_runner_->RunsTasksOnCurrentThread());
// Valid contexts in which to call.
DCHECK(complete || 0 != input_contents_size_);
@@ -293,7 +294,7 @@ ByteStreamReaderImpl::ByteStreamReaderImpl(
my_task_runner_(task_runner),
my_lifetime_flag_(lifetime_flag),
received_status_(false),
- status_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
+ status_(DOWNLOAD_INTERRUPT_REASON_NONE),
unreported_consumed_bytes_(0),
peer_(NULL) {
DCHECK(my_lifetime_flag_.get());
@@ -333,8 +334,7 @@ ByteStreamReaderImpl::Read(scoped_refptr<net::IOBuffer>* data,
return STREAM_EMPTY;
}
-content::DownloadInterruptReason
-ByteStreamReaderImpl::GetStatus() const {
+DownloadInterruptReason ByteStreamReaderImpl::GetStatus() const {
DCHECK(my_task_runner_->RunsTasksOnCurrentThread());
DCHECK(received_status_);
return status_;
@@ -354,7 +354,7 @@ void ByteStreamReaderImpl::TransferData(
scoped_ptr<ContentVector> transfer_buffer,
size_t buffer_size,
bool source_complete,
- content::DownloadInterruptReason status) {
+ DownloadInterruptReason status) {
// If our target is no longer alive, do nothing.
if (!object_lifetime_flag->is_alive) return;
@@ -366,7 +366,7 @@ void ByteStreamReaderImpl::TransferDataInternal(
scoped_ptr<ContentVector> transfer_buffer,
size_t buffer_size,
bool source_complete,
- content::DownloadInterruptReason status) {
+ DownloadInterruptReason status) {
DCHECK(my_task_runner_->RunsTasksOnCurrentThread());
bool was_empty = available_contents_.empty();
@@ -411,8 +411,6 @@ void ByteStreamReaderImpl::MaybeUpdateInput() {
} // namespace
-namespace content {
-
ByteStreamReader::~ByteStreamReader() { }
ByteStreamWriter::~ByteStreamWriter() { }
diff --git a/content/browser/download/byte_stream.h b/content/browser/download/byte_stream.h
index b48bc4a..39f5af4 100644
--- a/content/browser/download/byte_stream.h
+++ b/content/browser/download/byte_stream.h
@@ -64,7 +64,7 @@ namespace content {
// // Create a stream for sending bytes from IO->FILE threads.
// scoped_ptr<ByteStreamWriter> writer;
// scoped_ptr<ByteStreamReader> reader;
-// content::CreateByteStream(
+// CreateByteStream(
// BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
// BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
// kStreamBufferSize /* e.g. 10240. */,
@@ -107,13 +107,13 @@ namespace content {
// scoped_refptr<net::IOBuffer> data;
// size_t length = 0;
//
-// while (content::ByteStreamReader::STREAM_HAS_DATA ==
+// while (ByteStreamReader::STREAM_HAS_DATA ==
// (state = reader->Read(&data, &length))) {
// // Process |data|.
// }
//
-// if (content::ByteStreamReader::STREAM_COMPLETE == state) {
-// content::DownloadInterruptReason status = reader->GetStatus();
+// if (ByteStreamReader::STREAM_COMPLETE == state) {
+// DownloadInterruptReason status = reader->GetStatus();
// // Process error or successful completion in |status|.
// }
//
diff --git a/content/browser/download/byte_stream_unittest.cc b/content/browser/download/byte_stream_unittest.cc
index 426211e..1f1d669 100644
--- a/content/browser/download/byte_stream_unittest.cc
+++ b/content/browser/download/byte_stream_unittest.cc
@@ -25,6 +25,7 @@ namespace tracked_objects {
class Location;
}
+namespace content {
namespace {
class MockTaskRunner : public base::SequencedTaskRunner {
@@ -78,8 +79,7 @@ class ByteStreamTest : public testing::Test {
// ByteStream, returning the result of the ByteStream::Write.
// Separate function to avoid duplication of buffer_size in test
// calls.
- bool Write(content::ByteStreamWriter* byte_stream_input,
- size_t buffer_size) {
+ bool Write(ByteStreamWriter* byte_stream_input, size_t buffer_size) {
return byte_stream_input->Write(NewIOBuffer(buffer_size), buffer_size);
}
@@ -135,9 +135,9 @@ ByteStreamTest::ByteStreamTest()
// Confirm that filling and emptying the stream works properly, and that
// we get full triggers when we expect.
TEST_F(ByteStreamTest, ByteStream_PushBack) {
- scoped_ptr<content::ByteStreamWriter> byte_stream_input;
- scoped_ptr<content::ByteStreamReader> byte_stream_output;
- content::CreateByteStream(
+ scoped_ptr<ByteStreamWriter> byte_stream_input;
+ scoped_ptr<ByteStreamReader> byte_stream_output;
+ CreateByteStream(
message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(),
3 * 1024, &byte_stream_input, &byte_stream_output);
@@ -149,34 +149,34 @@ TEST_F(ByteStreamTest, ByteStream_PushBack) {
EXPECT_FALSE(Write(byte_stream_input.get(), 1));
EXPECT_FALSE(Write(byte_stream_input.get(), 1024));
// Flush
- byte_stream_input->Close(content::DOWNLOAD_INTERRUPT_REASON_NONE);
+ byte_stream_input->Close(DOWNLOAD_INTERRUPT_REASON_NONE);
message_loop_.RunAllPending();
// Pull the IO buffers out; do we get the same buffers and do they
// have the same contents?
scoped_refptr<net::IOBuffer> output_io_buffer;
size_t output_length;
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_COMPLETE,
+ EXPECT_EQ(ByteStreamReader::STREAM_COMPLETE,
byte_stream_output->Read(&output_io_buffer, &output_length));
}
@@ -184,9 +184,9 @@ TEST_F(ByteStreamTest, ByteStream_PushBack) {
// that we're getting pushback even when data's split across the two
// objects
TEST_F(ByteStreamTest, ByteStream_PushBackSplit) {
- scoped_ptr<content::ByteStreamWriter> byte_stream_input;
- scoped_ptr<content::ByteStreamReader> byte_stream_output;
- content::CreateByteStream(
+ scoped_ptr<ByteStreamWriter> byte_stream_input;
+ scoped_ptr<ByteStreamReader> byte_stream_output;
+ CreateByteStream(
message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(),
9 * 1024, &byte_stream_input, &byte_stream_output);
@@ -207,99 +207,97 @@ TEST_F(ByteStreamTest, ByteStream_PushBackSplit) {
// have the same contents?
scoped_refptr<net::IOBuffer> output_io_buffer;
size_t output_length;
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_EMPTY,
+ EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
byte_stream_output->Read(&output_io_buffer, &output_length));
}
// Confirm that a Close() notification transmits in-order
// with data on the stream.
TEST_F(ByteStreamTest, ByteStream_CompleteTransmits) {
- scoped_ptr<content::ByteStreamWriter> byte_stream_input;
- scoped_ptr<content::ByteStreamReader> byte_stream_output;
+ scoped_ptr<ByteStreamWriter> byte_stream_input;
+ scoped_ptr<ByteStreamReader> byte_stream_output;
scoped_refptr<net::IOBuffer> output_io_buffer;
size_t output_length;
// Empty stream, non-error case.
- content::CreateByteStream(
+ CreateByteStream(
message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(),
3 * 1024, &byte_stream_input, &byte_stream_output);
- EXPECT_EQ(content::ByteStreamReader::STREAM_EMPTY,
+ EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
byte_stream_output->Read(&output_io_buffer, &output_length));
- byte_stream_input->Close(content::DOWNLOAD_INTERRUPT_REASON_NONE);
+ byte_stream_input->Close(DOWNLOAD_INTERRUPT_REASON_NONE);
message_loop_.RunAllPending();
- ASSERT_EQ(content::ByteStreamReader::STREAM_COMPLETE,
+ ASSERT_EQ(ByteStreamReader::STREAM_COMPLETE,
byte_stream_output->Read(&output_io_buffer, &output_length));
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
byte_stream_output->GetStatus());
// Non-empty stream, non-error case.
- content::CreateByteStream(
+ CreateByteStream(
message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(),
3 * 1024, &byte_stream_input, &byte_stream_output);
- EXPECT_EQ(content::ByteStreamReader::STREAM_EMPTY,
+ EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(Write(byte_stream_input.get(), 1024));
- byte_stream_input->Close(content::DOWNLOAD_INTERRUPT_REASON_NONE);
+ byte_stream_input->Close(DOWNLOAD_INTERRUPT_REASON_NONE);
message_loop_.RunAllPending();
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- ASSERT_EQ(content::ByteStreamReader::STREAM_COMPLETE,
+ ASSERT_EQ(ByteStreamReader::STREAM_COMPLETE,
byte_stream_output->Read(&output_io_buffer, &output_length));
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
byte_stream_output->GetStatus());
// Empty stream, non-error case.
- content::CreateByteStream(
+ CreateByteStream(
message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(),
3 * 1024, &byte_stream_input, &byte_stream_output);
- EXPECT_EQ(content::ByteStreamReader::STREAM_EMPTY,
+ EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
byte_stream_output->Read(&output_io_buffer, &output_length));
- byte_stream_input->Close(
- content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED);
+ byte_stream_input->Close(DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED);
message_loop_.RunAllPending();
- ASSERT_EQ(content::ByteStreamReader::STREAM_COMPLETE,
+ ASSERT_EQ(ByteStreamReader::STREAM_COMPLETE,
byte_stream_output->Read(&output_io_buffer, &output_length));
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED,
byte_stream_output->GetStatus());
// Non-empty stream, non-error case.
- content::CreateByteStream(
+ CreateByteStream(
message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(),
3 * 1024, &byte_stream_input, &byte_stream_output);
- EXPECT_EQ(content::ByteStreamReader::STREAM_EMPTY,
+ EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(Write(byte_stream_input.get(), 1024));
- byte_stream_input->Close(
- content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED);
+ byte_stream_input->Close(DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED);
message_loop_.RunAllPending();
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- ASSERT_EQ(content::ByteStreamReader::STREAM_COMPLETE,
+ ASSERT_EQ(ByteStreamReader::STREAM_COMPLETE,
byte_stream_output->Read(&output_io_buffer, &output_length));
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED,
byte_stream_output->GetStatus());
}
@@ -309,9 +307,9 @@ TEST_F(ByteStreamTest, ByteStream_SinkCallback) {
EXPECT_CALL(*task_runner.get(), RunsTasksOnCurrentThread())
.WillRepeatedly(Return(true));
- scoped_ptr<content::ByteStreamWriter> byte_stream_input;
- scoped_ptr<content::ByteStreamReader> byte_stream_output;
- content::CreateByteStream(
+ scoped_ptr<ByteStreamWriter> byte_stream_input;
+ scoped_ptr<ByteStreamReader> byte_stream_output;
+ CreateByteStream(
message_loop_.message_loop_proxy(), task_runner,
10000, &byte_stream_input, &byte_stream_output);
@@ -346,10 +344,10 @@ TEST_F(ByteStreamTest, ByteStream_SinkCallback) {
EXPECT_EQ(1, num_callbacks);
// Check data and stream state.
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_EMPTY,
+ EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
byte_stream_output->Read(&output_io_buffer, &output_length));
// Confirm callback *isn't* called at less than 33% (by lack of
@@ -359,7 +357,7 @@ TEST_F(ByteStreamTest, ByteStream_SinkCallback) {
// This reflects an implementation artifact that data goes with callbacks,
// which should not be considered part of the interface guarantee.
- EXPECT_EQ(content::ByteStreamReader::STREAM_EMPTY,
+ EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
byte_stream_output->Read(&output_io_buffer, &output_length));
}
@@ -370,9 +368,9 @@ TEST_F(ByteStreamTest, ByteStream_SourceCallback) {
EXPECT_CALL(*task_runner.get(), RunsTasksOnCurrentThread())
.WillRepeatedly(Return(true));
- scoped_ptr<content::ByteStreamWriter> byte_stream_input;
- scoped_ptr<content::ByteStreamReader> byte_stream_output;
- content::CreateByteStream(
+ scoped_ptr<ByteStreamWriter> byte_stream_input;
+ scoped_ptr<ByteStreamReader> byte_stream_output;
+ CreateByteStream(
task_runner, message_loop_.message_loop_proxy(),
10000, &byte_stream_input, &byte_stream_output);
@@ -399,7 +397,7 @@ TEST_F(ByteStreamTest, ByteStream_SourceCallback) {
// Allow bytes to transition (needed for message passing implementation),
// and get and validate the data.
message_loop_.RunAllPending();
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
@@ -410,7 +408,7 @@ TEST_F(ByteStreamTest, ByteStream_SourceCallback) {
// Grab data, triggering callback. Recorded on dispatch, but doesn't
// happen because it's caught by the mock.
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
::testing::Mock::VerifyAndClearExpectations(task_runner.get());
EXPECT_CALL(*task_runner.get(), RunsTasksOnCurrentThread())
@@ -426,13 +424,13 @@ TEST_F(ByteStreamTest, ByteStream_SourceCallback) {
EXPECT_CALL(*task_runner.get(), PostDelayedTask(_, _, base::TimeDelta()))
.WillOnce(DoAll(SaveArg<1>(&intermediate_callback),
Return(true)));
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
::testing::Mock::VerifyAndClearExpectations(task_runner.get());
EXPECT_CALL(*task_runner.get(), RunsTasksOnCurrentThread())
.WillRepeatedly(Return(true));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_EMPTY,
+ EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_EQ(1, num_callbacks);
intermediate_callback.Run();
@@ -448,9 +446,9 @@ TEST_F(ByteStreamTest, ByteStream_SinkInterrupt) {
EXPECT_CALL(*task_runner.get(), RunsTasksOnCurrentThread())
.WillRepeatedly(Return(true));
- scoped_ptr<content::ByteStreamWriter> byte_stream_input;
- scoped_ptr<content::ByteStreamReader> byte_stream_output;
- content::CreateByteStream(
+ scoped_ptr<ByteStreamWriter> byte_stream_input;
+ scoped_ptr<ByteStreamReader> byte_stream_output;
+ CreateByteStream(
message_loop_.message_loop_proxy(), task_runner,
10000, &byte_stream_input, &byte_stream_output);
@@ -487,10 +485,10 @@ TEST_F(ByteStreamTest, ByteStream_SinkInterrupt) {
EXPECT_EQ(1, num_alt_callbacks);
// Final cleanup.
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_EMPTY,
+ EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
byte_stream_output->Read(&output_io_buffer, &output_length));
}
@@ -502,9 +500,9 @@ TEST_F(ByteStreamTest, ByteStream_SourceInterrupt) {
EXPECT_CALL(*task_runner.get(), RunsTasksOnCurrentThread())
.WillRepeatedly(Return(true));
- scoped_ptr<content::ByteStreamWriter> byte_stream_input;
- scoped_ptr<content::ByteStreamReader> byte_stream_output;
- content::CreateByteStream(
+ scoped_ptr<ByteStreamWriter> byte_stream_input;
+ scoped_ptr<ByteStreamReader> byte_stream_output;
+ CreateByteStream(
task_runner, message_loop_.message_loop_proxy(),
10000, &byte_stream_input, &byte_stream_output);
@@ -522,7 +520,7 @@ TEST_F(ByteStreamTest, ByteStream_SourceInterrupt) {
message_loop_.RunAllPending();
// Initial get should not trigger callback.
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
message_loop_.RunAllPending();
@@ -533,7 +531,7 @@ TEST_F(ByteStreamTest, ByteStream_SourceInterrupt) {
Return(true)));
// Second get *should* trigger callback.
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
::testing::Mock::VerifyAndClearExpectations(task_runner.get());
EXPECT_CALL(*task_runner.get(), RunsTasksOnCurrentThread())
@@ -552,13 +550,13 @@ TEST_F(ByteStreamTest, ByteStream_SourceInterrupt) {
EXPECT_CALL(*task_runner.get(), PostDelayedTask(_, _, base::TimeDelta()))
.WillOnce(DoAll(SaveArg<1>(&intermediate_callback),
Return(true)));
- EXPECT_EQ(content::ByteStreamReader::STREAM_HAS_DATA,
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
byte_stream_output->Read(&output_io_buffer, &output_length));
::testing::Mock::VerifyAndClearExpectations(task_runner.get());
EXPECT_CALL(*task_runner.get(), RunsTasksOnCurrentThread())
.WillRepeatedly(Return(true));
EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
- EXPECT_EQ(content::ByteStreamReader::STREAM_EMPTY,
+ EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
byte_stream_output->Read(&output_io_buffer, &output_length));
}
@@ -569,9 +567,9 @@ TEST_F(ByteStreamTest, ByteStream_ZeroCallback) {
EXPECT_CALL(*task_runner.get(), RunsTasksOnCurrentThread())
.WillRepeatedly(Return(true));
- scoped_ptr<content::ByteStreamWriter> byte_stream_input;
- scoped_ptr<content::ByteStreamReader> byte_stream_output;
- content::CreateByteStream(
+ scoped_ptr<ByteStreamWriter> byte_stream_input;
+ scoped_ptr<ByteStreamReader> byte_stream_output;
+ CreateByteStream(
message_loop_.message_loop_proxy(), task_runner,
10000, &byte_stream_input, &byte_stream_output);
@@ -586,7 +584,7 @@ TEST_F(ByteStreamTest, ByteStream_ZeroCallback) {
Return(true)));
// Immediately close the stream.
- byte_stream_input->Close(content::DOWNLOAD_INTERRUPT_REASON_NONE);
+ byte_stream_input->Close(DOWNLOAD_INTERRUPT_REASON_NONE);
::testing::Mock::VerifyAndClearExpectations(task_runner.get());
EXPECT_CALL(*task_runner.get(), RunsTasksOnCurrentThread())
.WillRepeatedly(Return(true));
@@ -594,3 +592,4 @@ TEST_F(ByteStreamTest, ByteStream_ZeroCallback) {
EXPECT_EQ(1, num_callbacks);
}
+} // namespace content
diff --git a/content/browser/download/download_browsertest.cc b/content/browser/download/download_browsertest.cc
index 0f7f8ad..65c1d9e 100644
--- a/content/browser/download/download_browsertest.cc
+++ b/content/browser/download/download_browsertest.cc
@@ -279,16 +279,16 @@ bool WasPersisted(DownloadItem* item) {
class CountingDownloadFile : public DownloadFileImpl {
public:
CountingDownloadFile(
- scoped_ptr<content::DownloadSaveInfo> save_info,
+ scoped_ptr<DownloadSaveInfo> save_info,
const FilePath& default_downloads_directory,
const GURL& url,
const GURL& referrer_url,
int64 received_bytes,
bool calculate_hash,
- scoped_ptr<content::ByteStreamReader> stream,
+ scoped_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
- scoped_ptr<content::PowerSaveBlocker> power_save_blocker,
- base::WeakPtr<content::DownloadDestinationObserver> observer)
+ scoped_ptr<PowerSaveBlocker> power_save_blocker,
+ base::WeakPtr<DownloadDestinationObserver> observer)
: DownloadFileImpl(save_info.Pass(), default_downloads_directory,
url, referrer_url, received_bytes, calculate_hash,
stream.Pass(), bound_net_log,
@@ -334,16 +334,16 @@ class CountingDownloadFileFactory : public DownloadFileFactory {
virtual ~CountingDownloadFileFactory() {}
// DownloadFileFactory interface.
- virtual content::DownloadFile* CreateFile(
- scoped_ptr<content::DownloadSaveInfo> save_info,
+ virtual DownloadFile* CreateFile(
+ scoped_ptr<DownloadSaveInfo> save_info,
const FilePath& default_downloads_directory,
const GURL& url,
const GURL& referrer_url,
int64 received_bytes,
bool calculate_hash,
- scoped_ptr<content::ByteStreamReader> stream,
+ scoped_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
- base::WeakPtr<content::DownloadDestinationObserver> observer) OVERRIDE {
+ base::WeakPtr<DownloadDestinationObserver> observer) OVERRIDE {
scoped_ptr<PowerSaveBlocker> psb(
new PowerSaveBlocker(
PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
@@ -397,7 +397,7 @@ class DownloadContentTest : public ContentBrowserTest {
// Note: Cannot be used with other alternative DownloadFileFactorys
void SetupEnsureNoPendingDownloads() {
DownloadManagerForShell(shell())->SetDownloadFileFactoryForTesting(
- scoped_ptr<content::DownloadFileFactory>(
+ scoped_ptr<DownloadFileFactory>(
new CountingDownloadFileFactory()).Pass());
}
@@ -679,8 +679,7 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, ShutdownInProgress) {
EXPECT_EQ(DownloadItem::IN_PROGRESS, items[0]->GetState());
// Wait for it to be persisted.
- content::DownloadUpdatedObserver(
- items[0], base::Bind(&WasPersisted)).WaitForEvent();
+ DownloadUpdatedObserver(items[0], base::Bind(&WasPersisted)).WaitForEvent();
// Shutdown the download manager and make sure we get the right
// notifications in the right order.
@@ -715,7 +714,7 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, ShutdownAtRelease) {
DownloadFileWithDelayFactory* file_factory =
new DownloadFileWithDelayFactory();
DownloadManagerForShell(shell())->SetDownloadFileFactoryForTesting(
- scoped_ptr<content::DownloadFileFactory>(file_factory).Pass());
+ scoped_ptr<DownloadFileFactory>(file_factory).Pass());
// Create a download
FilePath file(FILE_PATH_LITERAL("download-test.lib"));
diff --git a/content/browser/download/download_create_info.cc b/content/browser/download/download_create_info.cc
index bef5aa4..db01bcd 100644
--- a/content/browser/download/download_create_info.cc
+++ b/content/browser/download/download_create_info.cc
@@ -9,7 +9,7 @@
#include "base/format_macros.h"
#include "base/stringprintf.h"
-using content::DownloadId;
+namespace content {
DownloadCreateInfo::DownloadCreateInfo(
const base::Time& start_time,
@@ -18,7 +18,7 @@ DownloadCreateInfo::DownloadCreateInfo(
int32 state,
const net::BoundNetLog& bound_net_log,
bool has_user_gesture,
- content::PageTransition transition_type)
+ PageTransition transition_type)
: start_time(start_time),
received_bytes(received_bytes),
total_bytes(total_bytes),
@@ -28,7 +28,7 @@ DownloadCreateInfo::DownloadCreateInfo(
transition_type(transition_type),
db_handle(0),
prompt_user_for_save_location(false),
- save_info(new content::DownloadSaveInfo()),
+ save_info(new DownloadSaveInfo()),
request_bound_net_log(bound_net_log) {
}
@@ -38,10 +38,10 @@ DownloadCreateInfo::DownloadCreateInfo()
state(-1),
download_id(DownloadId::Invalid()),
has_user_gesture(false),
- transition_type(content::PAGE_TRANSITION_LINK),
+ transition_type(PAGE_TRANSITION_LINK),
db_handle(0),
prompt_user_for_save_location(false),
- save_info(new content::DownloadSaveInfo()) {
+ save_info(new DownloadSaveInfo()) {
}
DownloadCreateInfo::~DownloadCreateInfo() {
@@ -65,3 +65,5 @@ std::string DownloadCreateInfo::DebugString() const {
const GURL& DownloadCreateInfo::url() const {
return url_chain.empty() ? GURL::EmptyGURL() : url_chain.back();
}
+
+} // namespace content
diff --git a/content/browser/download/download_create_info.h b/content/browser/download/download_create_info.h
index 2eef90c..068c573 100644
--- a/content/browser/download/download_create_info.h
+++ b/content/browser/download/download_create_info.h
@@ -20,6 +20,8 @@
#include "googleurl/src/gurl.h"
#include "net/base/net_log.h"
+namespace content {
+
// Used for informing the download manager of a new download, since we don't
// want to pass |DownloadItem|s between threads.
struct CONTENT_EXPORT DownloadCreateInfo {
@@ -29,7 +31,7 @@ struct CONTENT_EXPORT DownloadCreateInfo {
int32 state,
const net::BoundNetLog& bound_net_log,
bool has_user_gesture,
- content::PageTransition transition_type);
+ PageTransition transition_type);
DownloadCreateInfo();
~DownloadCreateInfo();
@@ -58,12 +60,12 @@ struct CONTENT_EXPORT DownloadCreateInfo {
int32 state;
// The (per-session) ID of the download.
- content::DownloadId download_id;
+ DownloadId download_id;
// True if the download was initiated by user action.
bool has_user_gesture;
- content::PageTransition transition_type;
+ PageTransition transition_type;
// The handle of the download in the history database.
int64 db_handle;
@@ -94,7 +96,7 @@ struct CONTENT_EXPORT DownloadCreateInfo {
bool prompt_user_for_save_location;
// The download file save info.
- scoped_ptr<content::DownloadSaveInfo> save_info;
+ scoped_ptr<DownloadSaveInfo> save_info;
// The remote IP address where the download was fetched from. Copied from
// UrlRequest::GetSocketAddress().
@@ -111,4 +113,6 @@ struct CONTENT_EXPORT DownloadCreateInfo {
DISALLOW_COPY_AND_ASSIGN(DownloadCreateInfo);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_
diff --git a/content/browser/download/download_file_impl.cc b/content/browser/download/download_file_impl.cc
index c018599..802fec5 100644
--- a/content/browser/download/download_file_impl.cc
+++ b/content/browser/download/download_file_impl.cc
@@ -20,26 +20,24 @@
#include "content/browser/download/download_stats.h"
#include "net/base/io_buffer.h"
-using content::BrowserThread;
-using content::DownloadId;
-using content::DownloadManager;
+namespace content {
const int kUpdatePeriodMs = 500;
const int kMaxTimeBlockingFileThreadMs = 1000;
-int content::DownloadFile::number_active_objects_ = 0;
+int DownloadFile::number_active_objects_ = 0;
DownloadFileImpl::DownloadFileImpl(
- scoped_ptr<content::DownloadSaveInfo> save_info,
+ scoped_ptr<DownloadSaveInfo> save_info,
const FilePath& default_download_directory,
const GURL& url,
const GURL& referrer_url,
int64 received_bytes,
bool calculate_hash,
- scoped_ptr<content::ByteStreamReader> stream,
+ scoped_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
- scoped_ptr<content::PowerSaveBlocker> power_save_blocker,
- base::WeakPtr<content::DownloadDestinationObserver> observer)
+ scoped_ptr<PowerSaveBlocker> power_save_blocker,
+ base::WeakPtr<DownloadDestinationObserver> observer)
: file_(save_info->file_path,
url,
referrer_url,
@@ -66,9 +64,9 @@ void DownloadFileImpl::Initialize(const InitializeCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
update_timer_.reset(new base::RepeatingTimer<DownloadFileImpl>());
- content::DownloadInterruptReason result =
+ DownloadInterruptReason result =
file_.Initialize(default_download_directory_);
- if (result != content::DOWNLOAD_INTERRUPT_REASON_NONE) {
+ if (result != DOWNLOAD_INTERRUPT_REASON_NONE) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, base::Bind(callback, result));
return;
@@ -84,12 +82,12 @@ void DownloadFileImpl::Initialize(const InitializeCallback& callback) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, base::Bind(
- callback, content::DOWNLOAD_INTERRUPT_REASON_NONE));
+ callback, DOWNLOAD_INTERRUPT_REASON_NONE));
++number_active_objects_;
}
-content::DownloadInterruptReason DownloadFileImpl::AppendDataToFile(
+DownloadInterruptReason DownloadFileImpl::AppendDataToFile(
const char* data, size_t data_len) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
@@ -117,8 +115,8 @@ void DownloadFileImpl::Rename(const FilePath& full_path,
}
}
- content::DownloadInterruptReason reason = file_.Rename(new_path);
- if (reason != content::DOWNLOAD_INTERRUPT_REASON_NONE) {
+ DownloadInterruptReason reason = file_.Rename(new_path);
+ if (reason != DOWNLOAD_INTERRUPT_REASON_NONE) {
// Make sure our information is updated, since we're about to
// error out.
SendUpdate();
@@ -188,10 +186,8 @@ void DownloadFileImpl::StreamActive() {
size_t incoming_data_size = 0;
size_t total_incoming_data_size = 0;
size_t num_buffers = 0;
- content::ByteStreamReader::StreamState state(
- content::ByteStreamReader::STREAM_EMPTY);
- content::DownloadInterruptReason reason =
- content::DOWNLOAD_INTERRUPT_REASON_NONE;
+ ByteStreamReader::StreamState state(ByteStreamReader::STREAM_EMPTY);
+ DownloadInterruptReason reason = DOWNLOAD_INTERRUPT_REASON_NONE;
base::TimeDelta delta(
base::TimeDelta::FromMilliseconds(kMaxTimeBlockingFileThreadMs));
@@ -200,9 +196,9 @@ void DownloadFileImpl::StreamActive() {
state = stream_reader_->Read(&incoming_data, &incoming_data_size);
switch (state) {
- case content::ByteStreamReader::STREAM_EMPTY:
+ case ByteStreamReader::STREAM_EMPTY:
break;
- case content::ByteStreamReader::STREAM_HAS_DATA:
+ case ByteStreamReader::STREAM_HAS_DATA:
{
++num_buffers;
base::TimeTicks write_start(base::TimeTicks::Now());
@@ -213,7 +209,7 @@ void DownloadFileImpl::StreamActive() {
total_incoming_data_size += incoming_data_size;
}
break;
- case content::ByteStreamReader::STREAM_COMPLETE:
+ case ByteStreamReader::STREAM_COMPLETE:
{
reason = stream_reader_->GetStatus();
SendUpdate();
@@ -221,7 +217,7 @@ void DownloadFileImpl::StreamActive() {
file_.Finish();
base::TimeTicks now(base::TimeTicks::Now());
disk_writes_time_ += (now - close_start);
- download_stats::RecordFileBandwidth(
+ RecordFileBandwidth(
bytes_seen_, disk_writes_time_, now - download_start_);
update_timer_.reset();
}
@@ -231,12 +227,12 @@ void DownloadFileImpl::StreamActive() {
break;
}
now = base::TimeTicks::Now();
- } while (state == content::ByteStreamReader::STREAM_HAS_DATA &&
- reason == content::DOWNLOAD_INTERRUPT_REASON_NONE &&
+ } while (state == ByteStreamReader::STREAM_HAS_DATA &&
+ reason == DOWNLOAD_INTERRUPT_REASON_NONE &&
now - start <= delta);
// If we're stopping to yield the thread, post a task so we come back.
- if (state == content::ByteStreamReader::STREAM_HAS_DATA &&
+ if (state == ByteStreamReader::STREAM_HAS_DATA &&
now - start > delta) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
@@ -245,12 +241,12 @@ void DownloadFileImpl::StreamActive() {
}
if (total_incoming_data_size)
- download_stats::RecordFileThreadReceiveBuffers(num_buffers);
+ RecordFileThreadReceiveBuffers(num_buffers);
- download_stats::RecordContiguousWriteTime(now - start);
+ RecordContiguousWriteTime(now - start);
// Take care of communication with our observer.
- if (reason != content::DOWNLOAD_INTERRUPT_REASON_NONE) {
+ if (reason != DOWNLOAD_INTERRUPT_REASON_NONE) {
// Error case for both upstream source and file write.
// Shut down processing and signal an error to our observer.
// Our observer will clean us up.
@@ -259,9 +255,9 @@ void DownloadFileImpl::StreamActive() {
SendUpdate(); // Make info up to date before error.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- base::Bind(&content::DownloadDestinationObserver::DestinationError,
+ base::Bind(&DownloadDestinationObserver::DestinationError,
observer_, reason));
- } else if (state == content::ByteStreamReader::STREAM_COMPLETE) {
+ } else if (state == ByteStreamReader::STREAM_COMPLETE) {
// Signal successful completion and shut down processing.
stream_reader_->RegisterCallback(base::Closure());
weak_factory_.InvalidateWeakPtrs();
@@ -272,26 +268,27 @@ void DownloadFileImpl::StreamActive() {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(
- &content::DownloadDestinationObserver::DestinationCompleted,
+ &DownloadDestinationObserver::DestinationCompleted,
observer_, hash));
}
if (bound_net_log_.IsLoggingAllEvents()) {
bound_net_log_.AddEvent(
net::NetLog::TYPE_DOWNLOAD_STREAM_DRAINED,
- base::Bind(&download_net_logs::FileStreamDrainedCallback,
- total_incoming_data_size, num_buffers));
+ base::Bind(&FileStreamDrainedNetLogCallback, total_incoming_data_size,
+ num_buffers));
}
}
void DownloadFileImpl::SendUpdate() {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- base::Bind(&content::DownloadDestinationObserver::DestinationUpdate,
+ base::Bind(&DownloadDestinationObserver::DestinationUpdate,
observer_, BytesSoFar(), CurrentSpeed(), GetHashState()));
}
// static
-int content::DownloadFile::GetNumberOfDownloadFiles() {
+int DownloadFile::GetNumberOfDownloadFiles() {
return number_active_objects_;
}
+} // namespace content
diff --git a/content/browser/download/download_file_impl.h b/content/browser/download/download_file_impl.h
index 11424af..05ff9a7 100644
--- a/content/browser/download/download_file_impl.h
+++ b/content/browser/download/download_file_impl.h
@@ -17,16 +17,14 @@
#include "content/public/browser/download_save_info.h"
#include "net/base/net_log.h"
-struct DownloadCreateInfo;
-
namespace content {
class ByteStreamReader;
class DownloadDestinationObserver;
class DownloadManager;
class PowerSaveBlocker;
-}
+struct DownloadCreateInfo;
-class CONTENT_EXPORT DownloadFileImpl : virtual public content::DownloadFile {
+class CONTENT_EXPORT DownloadFileImpl : virtual public DownloadFile {
public:
// Takes ownership of the object pointed to by |request_handle|.
// |bound_net_log| will be used for logging the download file's events.
@@ -37,16 +35,16 @@ class CONTENT_EXPORT DownloadFileImpl : virtual public content::DownloadFile {
// stream, and sends updates and status of those reads to the
// DownloadDestinationObserver.
DownloadFileImpl(
- scoped_ptr<content::DownloadSaveInfo> save_info,
+ scoped_ptr<DownloadSaveInfo> save_info,
const FilePath& default_downloads_directory,
const GURL& url,
const GURL& referrer_url,
int64 received_bytes,
bool calculate_hash,
- scoped_ptr<content::ByteStreamReader> stream,
+ scoped_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
- scoped_ptr<content::PowerSaveBlocker> power_save_blocker,
- base::WeakPtr<content::DownloadDestinationObserver> observer);
+ scoped_ptr<PowerSaveBlocker> power_save_blocker,
+ base::WeakPtr<DownloadDestinationObserver> observer);
virtual ~DownloadFileImpl();
@@ -67,7 +65,7 @@ class CONTENT_EXPORT DownloadFileImpl : virtual public content::DownloadFile {
protected:
// For test class overrides.
- virtual content::DownloadInterruptReason AppendDataToFile(
+ virtual DownloadInterruptReason AppendDataToFile(
const char* data, size_t data_len);
private:
@@ -88,7 +86,7 @@ class CONTENT_EXPORT DownloadFileImpl : virtual public content::DownloadFile {
// TODO(rdsmith): Move this into BaseFile; requires using the same
// stream semantics in SavePackage. Alternatively, replace SaveFile
// with DownloadFile and get rid of BaseFile.
- scoped_ptr<content::ByteStreamReader> stream_reader_;
+ scoped_ptr<ByteStreamReader> stream_reader_;
// Used to trigger progress updates.
scoped_ptr<base::RepeatingTimer<DownloadFileImpl> > update_timer_;
@@ -100,14 +98,16 @@ class CONTENT_EXPORT DownloadFileImpl : virtual public content::DownloadFile {
net::BoundNetLog bound_net_log_;
- base::WeakPtr<content::DownloadDestinationObserver> observer_;
+ base::WeakPtr<DownloadDestinationObserver> observer_;
base::WeakPtrFactory<DownloadFileImpl> weak_factory_;
// RAII handle to keep the system from sleeping while we're downloading.
- scoped_ptr<content::PowerSaveBlocker> power_save_blocker_;
+ scoped_ptr<PowerSaveBlocker> power_save_blocker_;
DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_
diff --git a/content/browser/download/download_file_unittest.cc b/content/browser/download/download_file_unittest.cc
index b260179..ca3d3c7 100644
--- a/content/browser/download/download_file_unittest.cc
+++ b/content/browser/download/download_file_unittest.cc
@@ -22,10 +22,6 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-using content::BrowserThread;
-using content::BrowserThreadImpl;
-using content::DownloadFile;
-using content::DownloadId;
using ::testing::_;
using ::testing::AnyNumber;
using ::testing::DoAll;
@@ -34,25 +30,25 @@ using ::testing::Return;
using ::testing::SetArgPointee;
using ::testing::StrictMock;
+namespace content {
namespace {
-class MockByteStreamReader : public content::ByteStreamReader {
+class MockByteStreamReader : public ByteStreamReader {
public:
MockByteStreamReader() {}
~MockByteStreamReader() {}
// ByteStream functions
- MOCK_METHOD2(Read, content::ByteStreamReader::StreamState(
+ MOCK_METHOD2(Read, ByteStreamReader::StreamState(
scoped_refptr<net::IOBuffer>*, size_t*));
- MOCK_CONST_METHOD0(GetStatus, content::DownloadInterruptReason());
+ MOCK_CONST_METHOD0(GetStatus, DownloadInterruptReason());
MOCK_METHOD1(RegisterCallback, void(const base::Closure&));
};
-class MockDownloadDestinationObserver
- : public content::DownloadDestinationObserver {
+class MockDownloadDestinationObserver : public DownloadDestinationObserver {
public:
MOCK_METHOD3(DestinationUpdate, void(int64, int64, const std::string&));
- MOCK_METHOD1(DestinationError, void(content::DownloadInterruptReason));
+ MOCK_METHOD1(DestinationError, void(DownloadInterruptReason));
MOCK_METHOD1(DestinationCompleted, void(const std::string&));
// Doesn't override any methods in the base class. Used to make sure
@@ -115,8 +111,8 @@ class DownloadFileTest : public testing::Test {
}
void SetInterruptReasonCallback(bool* was_called,
- content::DownloadInterruptReason* reason_p,
- content::DownloadInterruptReason reason) {
+ DownloadInterruptReason* reason_p,
+ DownloadInterruptReason reason) {
*was_called = true;
*reason_p = reason;
}
@@ -133,8 +129,7 @@ class DownloadFileTest : public testing::Test {
.WillOnce(Invoke(this, &DownloadFileTest::RegisterCallback))
.RetiresOnSaturation();
- scoped_ptr<content::DownloadSaveInfo> save_info(
- new content::DownloadSaveInfo());
+ scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo());
download_file_.reset(
new DownloadFileImpl(
save_info.Pass(),
@@ -143,18 +138,18 @@ class DownloadFileTest : public testing::Test {
GURL(), // Referrer
0, // Received bytes
calculate_hash,
- scoped_ptr<content::ByteStreamReader>(input_stream_),
+ scoped_ptr<ByteStreamReader>(input_stream_),
net::BoundNetLog(),
- scoped_ptr<content::PowerSaveBlocker>(NULL).Pass(),
+ scoped_ptr<PowerSaveBlocker>(NULL).Pass(),
observer_factory_.GetWeakPtr()));
EXPECT_CALL(*input_stream_, Read(_, _))
- .WillOnce(Return(content::ByteStreamReader::STREAM_EMPTY))
+ .WillOnce(Return(ByteStreamReader::STREAM_EMPTY))
.RetiresOnSaturation();
base::WeakPtrFactory<DownloadFileTest> weak_ptr_factory(this);
bool called = false;
- content::DownloadInterruptReason result;
+ DownloadInterruptReason result;
download_file_->Initialize(base::Bind(
&DownloadFileTest::SetInterruptReasonCallback,
weak_ptr_factory.GetWeakPtr(), &called, &result));
@@ -162,7 +157,7 @@ class DownloadFileTest : public testing::Test {
EXPECT_TRUE(called);
::testing::Mock::VerifyAndClearExpectations(input_stream_);
- return result == content::DOWNLOAD_INTERRUPT_REASON_NONE;
+ return result == DOWNLOAD_INTERRUPT_REASON_NONE;
}
virtual void DestroyDownloadFile(int offset) {
@@ -195,7 +190,7 @@ class DownloadFileTest : public testing::Test {
.InSequence(s)
.WillOnce(DoAll(SetArgPointee<0>(data),
SetArgPointee<1>(length),
- Return(content::ByteStreamReader::STREAM_HAS_DATA)))
+ Return(ByteStreamReader::STREAM_HAS_DATA)))
.RetiresOnSaturation();
expected_data_ += source_data;
}
@@ -214,17 +209,17 @@ class DownloadFileTest : public testing::Test {
SetupDataAppend(data_chunks, num_chunks, s1);
EXPECT_CALL(*input_stream_, Read(_, _))
.InSequence(s1)
- .WillOnce(Return(content::ByteStreamReader::STREAM_EMPTY))
+ .WillOnce(Return(ByteStreamReader::STREAM_EMPTY))
.RetiresOnSaturation();
sink_callback_.Run();
VerifyStreamAndSize();
}
- void SetupFinishStream(content::DownloadInterruptReason interrupt_reason,
+ void SetupFinishStream(DownloadInterruptReason interrupt_reason,
::testing::Sequence s) {
EXPECT_CALL(*input_stream_, Read(_, _))
.InSequence(s)
- .WillOnce(Return(content::ByteStreamReader::STREAM_COMPLETE))
+ .WillOnce(Return(ByteStreamReader::STREAM_COMPLETE))
.RetiresOnSaturation();
EXPECT_CALL(*input_stream_, GetStatus())
.InSequence(s)
@@ -234,8 +229,8 @@ class DownloadFileTest : public testing::Test {
.RetiresOnSaturation();
}
- void FinishStream(content::DownloadInterruptReason interrupt_reason,
- bool check_observer) {
+ void FinishStream(DownloadInterruptReason interrupt_reason,
+ bool check_observer) {
::testing::Sequence s1;
SetupFinishStream(interrupt_reason, s1);
sink_callback_.Run();
@@ -251,12 +246,11 @@ class DownloadFileTest : public testing::Test {
}
}
- content::DownloadInterruptReason Rename(
+ DownloadInterruptReason Rename(
const FilePath& full_path, bool overwrite_existing_file,
FilePath* result_path_p) {
base::WeakPtrFactory<DownloadFileTest> weak_ptr_factory(this);
- content::DownloadInterruptReason result_reason(
- content::DOWNLOAD_INTERRUPT_REASON_NONE);
+ DownloadInterruptReason result_reason(DOWNLOAD_INTERRUPT_REASON_NONE);
bool callback_was_called(false);
FilePath result_path;
@@ -273,8 +267,7 @@ class DownloadFileTest : public testing::Test {
protected:
scoped_ptr<StrictMock<MockDownloadDestinationObserver> > observer_;
- base::WeakPtrFactory<content::DownloadDestinationObserver>
- observer_factory_;
+ base::WeakPtrFactory<DownloadDestinationObserver> observer_factory_;
// DownloadFile instance we are testing.
scoped_ptr<DownloadFile> download_file_;
@@ -295,9 +288,9 @@ class DownloadFileTest : public testing::Test {
private:
void SetRenameResult(bool* called_p,
- content::DownloadInterruptReason* reason_p,
+ DownloadInterruptReason* reason_p,
FilePath* result_path_p,
- content::DownloadInterruptReason reason,
+ DownloadInterruptReason reason,
const FilePath& result_path) {
if (called_p)
*called_p = true;
@@ -341,7 +334,7 @@ TEST_F(DownloadFileTest, RenameFileFinal) {
FilePath output_path;
// Rename the file before downloading any data.
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
Rename(path_1, false, &output_path));
FilePath renamed_path = download_file_->FullPath();
EXPECT_EQ(path_1, renamed_path);
@@ -356,7 +349,7 @@ TEST_F(DownloadFileTest, RenameFileFinal) {
AppendDataToFile(chunks1, 2);
// Rename the file after downloading some data.
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
Rename(path_2, false, &output_path));
renamed_path = download_file_->FullPath();
EXPECT_EQ(path_2, renamed_path);
@@ -370,7 +363,7 @@ TEST_F(DownloadFileTest, RenameFileFinal) {
AppendDataToFile(chunks2, 1);
// Rename the file after downloading all the data.
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
Rename(path_3, false, &output_path));
renamed_path = download_file_->FullPath();
EXPECT_EQ(path_3, renamed_path);
@@ -383,11 +376,11 @@ TEST_F(DownloadFileTest, RenameFileFinal) {
// Should not be able to get the hash until the file is closed.
std::string hash;
EXPECT_FALSE(download_file_->GetHash(&hash));
- FinishStream(content::DOWNLOAD_INTERRUPT_REASON_NONE, true);
+ FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true);
loop_.RunAllPending();
// Rename the file after downloading all the data and closing the file.
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
Rename(path_4, false, &output_path));
renamed_path = download_file_->FullPath();
EXPECT_EQ(path_4, renamed_path);
@@ -411,7 +404,7 @@ TEST_F(DownloadFileTest, RenameFileFinal) {
EXPECT_TRUE(file_util::ReadFileToString(path_5, &file_contents));
EXPECT_EQ(std::string(file_data), file_contents);
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
Rename(path_5, true, &output_path));
EXPECT_EQ(path_5, output_path);
@@ -437,11 +430,11 @@ TEST_F(DownloadFileTest, RenameUniquifies) {
file_util::WriteFile(path_1, file_data, sizeof(file_data)));
ASSERT_TRUE(file_util::PathExists(path_1));
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
Rename(path_1, false, NULL));
EXPECT_TRUE(file_util::PathExists(path_1_suffixed));
- FinishStream(content::DOWNLOAD_INTERRUPT_REASON_NONE, true);
+ FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true);
loop_.RunAllPending();
DestroyDownloadFile(0);
}
@@ -468,12 +461,12 @@ TEST_F(DownloadFileTest, RenameError) {
// Expect nulling out of further processing.
EXPECT_CALL(*input_stream_, RegisterCallback(IsNullCallback()));
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED,
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED,
Rename(target_path, true, NULL));
EXPECT_FALSE(file_util::PathExists(target_path_suffixed));
}
- FinishStream(content::DOWNLOAD_INTERRUPT_REASON_NONE, true);
+ FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true);
loop_.RunAllPending();
DestroyDownloadFile(0);
}
@@ -491,7 +484,7 @@ TEST_F(DownloadFileTest, StreamEmptySuccess) {
// Finish the download this way and make sure we see it on the
// observer.
EXPECT_CALL(*(observer_.get()), DestinationCompleted(_));
- FinishStream(content::DOWNLOAD_INTERRUPT_REASON_NONE, false);
+ FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, false);
loop_.RunAllPending();
DestroyDownloadFile(0);
@@ -506,7 +499,7 @@ TEST_F(DownloadFileTest, StreamEmptyError) {
// observer.
EXPECT_CALL(*(observer_.get()),
DestinationError(
- content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED))
+ DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED))
.WillOnce(InvokeWithoutArgs(
this, &DownloadFileTest::ConfirmUpdateDownloadInfo));
@@ -517,7 +510,7 @@ TEST_F(DownloadFileTest, StreamEmptyError) {
// same time.
EXPECT_CALL(*(observer_.get()), CurrentUpdateStatus(0, _, _));
- FinishStream(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED, false);
+ FinishStream(DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED, false);
loop_.RunAllPending();
@@ -532,7 +525,7 @@ TEST_F(DownloadFileTest, StreamNonEmptySuccess) {
const char* chunks1[] = { kTestData1, kTestData2 };
::testing::Sequence s1;
SetupDataAppend(chunks1, 2, s1);
- SetupFinishStream(content::DOWNLOAD_INTERRUPT_REASON_NONE, s1);
+ SetupFinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, s1);
EXPECT_CALL(*(observer_.get()), DestinationCompleted(_));
sink_callback_.Run();
VerifyStreamAndSize();
@@ -548,12 +541,11 @@ TEST_F(DownloadFileTest, StreamNonEmptyError) {
const char* chunks1[] = { kTestData1, kTestData2 };
::testing::Sequence s1;
SetupDataAppend(chunks1, 2, s1);
- SetupFinishStream(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED,
- s1);
+ SetupFinishStream(DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED, s1);
EXPECT_CALL(*(observer_.get()),
DestinationError(
- content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED))
+ DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED))
.WillOnce(InvokeWithoutArgs(
this, &DownloadFileTest::ConfirmUpdateDownloadInfo));
@@ -589,6 +581,8 @@ TEST_F(DownloadFileTest, ConfirmUpdate) {
bytes_);
EXPECT_EQ(download_file_->GetHashState(), hash_state_);
- FinishStream(content::DOWNLOAD_INTERRUPT_REASON_NONE, true);
+ FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true);
DestroyDownloadFile(0);
}
+
+} // namespace content
diff --git a/content/browser/download/download_id_unittest.cc b/content/browser/download/download_id_unittest.cc
index 15b7dc6..d59d33d 100644
--- a/content/browser/download/download_id_unittest.cc
+++ b/content/browser/download/download_id_unittest.cc
@@ -14,23 +14,19 @@
#include "content/public/test/mock_download_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
-using content::BrowserThread;
-using content::BrowserThreadImpl;
-using content::DownloadId;
-using content::DownloadManager;
+namespace content {
class DownloadIdTest : public testing::Test {
public:
DownloadIdTest()
: ui_thread_(BrowserThread::UI, &message_loop_) {
num_managers_ = ARRAYSIZE_UNSAFE(download_managers_);
- std::vector<content::MockDownloadManager*> managers;
+ std::vector<MockDownloadManager*> managers;
managers.resize(num_managers_);
size_t i;
// Create the download managers.
for (i = 0; i < num_managers_; ++i) {
- managers[i] =
- new content::MockDownloadManager();
+ managers[i] = new MockDownloadManager();
}
// Sort by pointer value.
std::sort(managers.begin(), managers.end());
@@ -151,3 +147,5 @@ TEST_F(DownloadIdTest, HashMap) {
EXPECT_FALSE(id1 == id2);
EXPECT_LT(id1, id2);
}
+
+} // namespace content
diff --git a/content/browser/download/download_item_factory.h b/content/browser/download/download_item_factory.h
index db32503..500f491 100644
--- a/content/browser/download/download_item_factory.h
+++ b/content/browser/download/download_item_factory.h
@@ -14,33 +14,30 @@
#include "base/memory/scoped_ptr.h"
#include "content/public/browser/download_id.h"
-struct DownloadCreateInfo;
-
-class DownloadItemImpl;
-class DownloadItemImplDelegate;
-class DownloadRequestHandleInterface;
class FilePath;
class GURL;
-namespace content {
-class DownloadItem;
-struct DownloadPersistentStoreInfo;
-}
-
namespace net {
class BoundNetLog;
}
namespace content {
+class DownloadItem;
+class DownloadItemImpl;
+class DownloadItemImplDelegate;
+class DownloadRequestHandleInterface;
+struct DownloadCreateInfo;
+struct DownloadPersistentStoreInfo;
+
class DownloadItemFactory {
public:
virtual ~DownloadItemFactory() {}
virtual DownloadItemImpl* CreatePersistedItem(
DownloadItemImplDelegate* delegate,
- content::DownloadId download_id,
- const content::DownloadPersistentStoreInfo& info,
+ DownloadId download_id,
+ const DownloadPersistentStoreInfo& info,
const net::BoundNetLog& bound_net_log) = 0;
virtual DownloadItemImpl* CreateActiveItem(
@@ -53,7 +50,7 @@ public:
DownloadItemImplDelegate* delegate,
const FilePath& path,
const GURL& url,
- content::DownloadId download_id,
+ DownloadId download_id,
const std::string& mime_type,
const net::BoundNetLog& bound_net_log) = 0;
};
diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc
index de2aab5..01d0e8c 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -47,14 +47,7 @@
#include "content/public/browser/download_persistent_store_info.h"
#include "net/base/net_util.h"
-using content::BrowserThread;
-using content::DownloadFile;
-using content::DownloadId;
-using content::DownloadItem;
-using content::DownloadManager;
-using content::DownloadPersistentStoreInfo;
-using content::WebContents;
-
+namespace content {
namespace {
static void DeleteDownloadedFile(const FilePath& path) {
@@ -119,8 +112,6 @@ static void DownloadFileCancel(scoped_ptr<DownloadFile> download_file) {
} // namespace
-namespace content {
-
// Our download table ID starts at 1, so we use 0 to represent a download that
// has started, but has not yet had its data persisted in the table. We use fake
// database handles in incognito mode starting at -1 and progressively getting
@@ -130,8 +121,6 @@ const int DownloadItem::kUninitializedHandle = 0;
const char DownloadItem::kEmptyFileHash[] = "";
-}
-
// Our download table ID starts at 1, so we use 0 to represent a download that
// has started, but has not yet had its data persisted in the table. We use fake
// database handles in incognito mode starting at -1 and progressively getting
@@ -149,15 +138,15 @@ DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
target_disposition_(TARGET_DISPOSITION_OVERWRITE),
url_chain_(1, info.url),
referrer_url_(info.referrer_url),
- transition_type_(content::PAGE_TRANSITION_LINK),
+ transition_type_(PAGE_TRANSITION_LINK),
has_user_gesture_(false),
total_bytes_(info.total_bytes),
received_bytes_(info.received_bytes),
bytes_per_sec_(0),
- last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
+ last_reason_(DOWNLOAD_INTERRUPT_REASON_NONE),
start_tick_(base::TimeTicks()),
state_(ExternalToInternalState(info.state)),
- danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
+ danger_type_(DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
start_time_(info.start_time),
end_time_(info.end_time),
db_handle_(info.db_handle),
@@ -180,8 +169,7 @@ DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
state_ = CANCELLED_INTERNAL;
if (state_ == COMPLETE_INTERNAL)
all_data_saved_ = true;
- Init(false /* not actively downloading */,
- download_net_logs::SRC_HISTORY_IMPORT);
+ Init(false /* not actively downloading */, SRC_HISTORY_IMPORT);
}
// Constructing for a regular download:
@@ -209,10 +197,10 @@ DownloadItemImpl::DownloadItemImpl(
total_bytes_(info.total_bytes),
received_bytes_(0),
bytes_per_sec_(0),
- last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
+ last_reason_(DOWNLOAD_INTERRUPT_REASON_NONE),
start_tick_(base::TimeTicks::Now()),
state_(IN_PROGRESS_INTERNAL),
- danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
+ danger_type_(DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
start_time_(info.start_time),
db_handle_(DownloadItem::kUninitializedHandle),
delegate_(delegate),
@@ -230,8 +218,7 @@ DownloadItemImpl::DownloadItemImpl(
bound_net_log_(bound_net_log),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
delegate_->Attach();
- Init(true /* actively downloading */,
- download_net_logs::SRC_NEW_DOWNLOAD);
+ Init(true /* actively downloading */, SRC_NEW_DOWNLOAD);
// Link the event sources.
bound_net_log_.AddEvent(
@@ -258,17 +245,17 @@ DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
target_disposition_(TARGET_DISPOSITION_OVERWRITE),
url_chain_(1, url),
referrer_url_(GURL()),
- transition_type_(content::PAGE_TRANSITION_LINK),
+ transition_type_(PAGE_TRANSITION_LINK),
has_user_gesture_(false),
mime_type_(mime_type),
original_mime_type_(mime_type),
total_bytes_(0),
received_bytes_(0),
bytes_per_sec_(0),
- last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
+ last_reason_(DOWNLOAD_INTERRUPT_REASON_NONE),
start_tick_(base::TimeTicks::Now()),
state_(IN_PROGRESS_INTERNAL),
- danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
+ danger_type_(DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
start_time_(base::Time::Now()),
db_handle_(DownloadItem::kUninitializedHandle),
delegate_(delegate),
@@ -286,8 +273,7 @@ DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
bound_net_log_(bound_net_log),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
delegate_->Attach();
- Init(true /* actively downloading */,
- download_net_logs::SRC_SAVE_PAGE_AS);
+ Init(true /* actively downloading */, SRC_SAVE_PAGE_AS);
}
DownloadItemImpl::~DownloadItemImpl() {
@@ -330,13 +316,13 @@ void DownloadItemImpl::DangerousDownloadValidated() {
UMA_HISTOGRAM_ENUMERATION("Download.DangerousDownloadValidated",
GetDangerType(),
- content::DOWNLOAD_DANGER_TYPE_MAX);
+ DOWNLOAD_DANGER_TYPE_MAX);
safety_state_ = DANGEROUS_BUT_VALIDATED;
bound_net_log_.AddEvent(
net::NetLog::TYPE_DOWNLOAD_ITEM_SAFETY_STATE_UPDATED,
- base::Bind(&download_net_logs::ItemCheckedCallback,
+ base::Bind(&ItemCheckedNetLogCallback,
GetDangerType(), GetSafetyState()));
UpdateObservers();
@@ -365,8 +351,8 @@ void DownloadItemImpl::Cancel(bool user_cancel) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
last_reason_ = user_cancel ?
- content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED :
- content::DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN;
+ DOWNLOAD_INTERRUPT_REASON_USER_CANCELED :
+ DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN;
VLOG(20) << __FUNCTION__ << "() download = " << DebugString(true);
if (state_ != IN_PROGRESS_INTERNAL) {
@@ -375,7 +361,7 @@ void DownloadItemImpl::Cancel(bool user_cancel) {
return;
}
- download_stats::RecordDownloadCount(download_stats::CANCELLED_COUNT);
+ RecordDownloadCount(CANCELLED_COUNT);
TransitionTo(CANCELLED_INTERNAL);
@@ -394,12 +380,12 @@ void DownloadItemImpl::Delete(DeleteReason reason) {
case DELETE_DUE_TO_USER_DISCARD:
UMA_HISTOGRAM_ENUMERATION(
"Download.UserDiscard", GetDangerType(),
- content::DOWNLOAD_DANGER_TYPE_MAX);
+ DOWNLOAD_DANGER_TYPE_MAX);
break;
case DELETE_DUE_TO_BROWSER_SHUTDOWN:
UMA_HISTOGRAM_ENUMERATION(
"Download.Discard", GetDangerType(),
- content::DOWNLOAD_DANGER_TYPE_MAX);
+ DOWNLOAD_DANGER_TYPE_MAX);
break;
default:
NOTREACHED();
@@ -446,7 +432,7 @@ void DownloadItemImpl::OpenDownload() {
// program that opens the file. So instead we spawn a check to update
// the UI if the file has been deleted in parallel with the open.
delegate_->CheckForFileRemoval(this);
- download_stats::RecordOpen(GetEndTime(), !GetOpened());
+ RecordOpen(GetEndTime(), !GetOpened());
opened_ = true;
FOR_EACH_OBSERVER(Observer, observers_, OnDownloadOpened(this));
delegate_->DownloadOpened(this);
@@ -456,13 +442,13 @@ void DownloadItemImpl::OpenDownload() {
if (!open_enabled_)
return;
- content::GetContentClient()->browser()->OpenItem(GetFullPath());
+ GetContentClient()->browser()->OpenItem(GetFullPath());
}
void DownloadItemImpl::ShowDownloadInShell() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- content::GetContentClient()->browser()->ShowItemInFolder(GetFullPath());
+ GetContentClient()->browser()->ShowItemInFolder(GetFullPath());
}
int32 DownloadItemImpl::GetId() const {
@@ -481,7 +467,7 @@ DownloadItem::DownloadState DownloadItemImpl::GetState() const {
return InternalToExternalState(state_);
}
-content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const {
+DownloadInterruptReason DownloadItemImpl::GetLastReason() const {
return last_reason_;
}
@@ -561,7 +547,7 @@ bool DownloadItemImpl::HasUserGesture() const {
return has_user_gesture_;
};
-content::PageTransition DownloadItemImpl::GetTransitionType() const {
+PageTransition DownloadItemImpl::GetTransitionType() const {
return transition_type_;
};
@@ -623,17 +609,17 @@ bool DownloadItemImpl::IsDangerous() const {
// TODO(noelutz): At this point only the windows views UI supports
// warnings based on dangerous content.
#ifdef OS_WIN
- return (danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
- danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL ||
- danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT ||
- danger_type_ == content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT);
+ return (danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
+ danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_URL ||
+ danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT ||
+ danger_type_ == DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT);
#else
- return (danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
- danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL);
+ return (danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
+ danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_URL);
#endif
}
-content::DownloadDangerType DownloadItemImpl::GetDangerType() const {
+DownloadDangerType DownloadItemImpl::GetDangerType() const {
return danger_type_;
}
@@ -723,7 +709,7 @@ DownloadPersistentStoreInfo DownloadItemImpl::GetPersistentStoreInfo() const {
GetOpened());
}
-content::BrowserContext* DownloadItemImpl::GetBrowserContext() const {
+BrowserContext* DownloadItemImpl::GetBrowserContext() const {
return delegate_->GetBrowserContext();
}
@@ -737,8 +723,7 @@ WebContents* DownloadItemImpl::GetWebContents() const {
return NULL;
}
-void DownloadItemImpl::OnContentCheckCompleted(
- content::DownloadDangerType danger_type) {
+void DownloadItemImpl::OnContentCheckCompleted(DownloadDangerType danger_type) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(AllDataSaved());
SetDangerType(danger_type);
@@ -831,7 +816,7 @@ void DownloadItemImpl::OnDownloadedFileRemoved() {
}
// An error occurred somewhere.
-void DownloadItemImpl::Interrupt(content::DownloadInterruptReason reason) {
+void DownloadItemImpl::Interrupt(DownloadInterruptReason reason) {
// Somewhat counter-intuitively, it is possible for us to receive an
// interrupt after we've already been interrupted. The generation of
// interrupts from the file thread Renames and the generation of
@@ -853,12 +838,11 @@ void DownloadItemImpl::Interrupt(content::DownloadInterruptReason reason) {
// Cancel the originating URL request.
request_handle_->CancelRequest();
- download_stats::RecordDownloadInterrupted(
- reason, received_bytes_, total_bytes_);
+ RecordDownloadInterrupted(reason, received_bytes_, total_bytes_);
delegate_->DownloadStopped(this);
}
-base::WeakPtr<content::DownloadDestinationObserver>
+base::WeakPtr<DownloadDestinationObserver>
DownloadItemImpl::DestinationObserverAsWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
@@ -979,8 +963,7 @@ void DownloadItemImpl::DestinationUpdate(int64 bytes_so_far,
UpdateObservers();
}
-void DownloadItemImpl::DestinationError(
- content::DownloadInterruptReason reason) {
+void DownloadItemImpl::DestinationError(DownloadInterruptReason reason) {
// The DestinationError and Interrupt routines are being kept separate
// to allow for a future merging of the Cancel and Interrupt routines..
Interrupt(reason);
@@ -996,16 +979,16 @@ void DownloadItemImpl::DestinationCompleted(const std::string& final_hash) {
// **** Download progression cascade
void DownloadItemImpl::Init(bool active,
- download_net_logs::DownloadType download_type) {
+ DownloadType download_type) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (active)
- download_stats::RecordDownloadCount(download_stats::START_COUNT);
+ RecordDownloadCount(START_COUNT);
if (target_path_.empty())
target_path_ = current_path_;
std::string file_name;
- if (download_type == download_net_logs::SRC_HISTORY_IMPORT) {
+ if (download_type == SRC_HISTORY_IMPORT) {
// target_path_ works for History and Save As versions.
file_name = target_path_.AsUTF8Unsafe();
} else {
@@ -1021,7 +1004,7 @@ void DownloadItemImpl::Init(bool active,
bound_net_log_.BeginEvent(
net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE,
- base::Bind(&download_net_logs::ItemActivatedCallback,
+ base::Bind(&ItemActivatedNetLogCallback,
this, download_type, &file_name));
// If this is not an active download, end the ACTIVE event now.
@@ -1037,7 +1020,7 @@ void DownloadItemImpl::Init(bool active,
}
// We're starting the download.
-void DownloadItemImpl::Start(scoped_ptr<content::DownloadFile> file) {
+void DownloadItemImpl::Start(scoped_ptr<DownloadFile> file) {
DCHECK(!download_file_.get());
DCHECK(file.get());
download_file_ = file.Pass();
@@ -1052,8 +1035,8 @@ void DownloadItemImpl::Start(scoped_ptr<content::DownloadFile> file) {
}
void DownloadItemImpl::OnDownloadFileInitialized(
- content::DownloadInterruptReason result) {
- if (result != content::DOWNLOAD_INTERRUPT_REASON_NONE) {
+ DownloadInterruptReason result) {
+ if (result != DOWNLOAD_INTERRUPT_REASON_NONE) {
Interrupt(result);
// TODO(rdsmith): It makes no sense to continue along the
// regular download path after we've gotten an error. But it's
@@ -1074,7 +1057,7 @@ void DownloadItemImpl::OnDownloadFileInitialized(
void DownloadItemImpl::OnDownloadTargetDetermined(
const FilePath& target_path,
TargetDisposition disposition,
- content::DownloadDangerType danger_type,
+ DownloadDangerType danger_type,
const FilePath& intermediate_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -1124,10 +1107,10 @@ void DownloadItemImpl::OnDownloadTargetDetermined(
}
void DownloadItemImpl::OnDownloadRenamedToIntermediateName(
- content::DownloadInterruptReason reason,
+ DownloadInterruptReason reason,
const FilePath& full_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (content::DOWNLOAD_INTERRUPT_REASON_NONE != reason) {
+ if (DOWNLOAD_INTERRUPT_REASON_NONE != reason) {
Interrupt(reason);
} else {
SetFullPath(full_path);
@@ -1202,7 +1185,7 @@ void DownloadItemImpl::ReadyForDownloadCompletionDone() {
DCHECK(download_file_.get());
if (NeedsRename()) {
- content::DownloadFile::RenameCompletionCallback callback =
+ DownloadFile::RenameCompletionCallback callback =
base::Bind(&DownloadItemImpl::OnDownloadRenamedToFinalName,
weak_ptr_factory_.GetWeakPtr());
BrowserThread::PostTask(
@@ -1216,7 +1199,7 @@ void DownloadItemImpl::ReadyForDownloadCompletionDone() {
}
void DownloadItemImpl::OnDownloadRenamedToFinalName(
- content::DownloadInterruptReason reason,
+ DownloadInterruptReason reason,
const FilePath& full_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -1232,7 +1215,7 @@ void DownloadItemImpl::OnDownloadRenamedToFinalName(
<< " " << DebugString(false);
DCHECK(NeedsRename());
- if (content::DOWNLOAD_INTERRUPT_REASON_NONE != reason) {
+ if (DOWNLOAD_INTERRUPT_REASON_NONE != reason) {
Interrupt(reason);
return;
}
@@ -1284,7 +1267,7 @@ void DownloadItemImpl::Completed() {
end_time_ = base::Time::Now();
TransitionTo(COMPLETE_INTERNAL);
delegate_->DownloadCompleted(this);
- download_stats::RecordDownloadCompleted(start_tick_, received_bytes_);
+ RecordDownloadCompleted(start_tick_, received_bytes_);
if (auto_opened_) {
// If it was already handled by the delegate, do nothing.
@@ -1357,26 +1340,24 @@ void DownloadItemImpl::TransitionTo(DownloadInternalState new_state) {
case COMPLETING_INTERNAL:
bound_net_log_.AddEvent(
net::NetLog::TYPE_DOWNLOAD_ITEM_COMPLETING,
- base::Bind(&download_net_logs::ItemCompletingCallback,
- received_bytes_, &hash_));
+ base::Bind(&ItemCompletingNetLogCallback, received_bytes_, &hash_));
break;
case COMPLETE_INTERNAL:
bound_net_log_.AddEvent(
net::NetLog::TYPE_DOWNLOAD_ITEM_FINISHED,
- base::Bind(&download_net_logs::ItemFinishedCallback,
- auto_opened_));
+ base::Bind(&ItemFinishedNetLogCallback, auto_opened_));
break;
case INTERRUPTED_INTERNAL:
bound_net_log_.AddEvent(
net::NetLog::TYPE_DOWNLOAD_ITEM_INTERRUPTED,
- base::Bind(&download_net_logs::ItemInterruptedCallback,
- last_reason_, received_bytes_, &hash_state_));
+ base::Bind(&ItemInterruptedNetLogCallback, last_reason_,
+ received_bytes_, &hash_state_));
break;
case CANCELLED_INTERNAL:
bound_net_log_.AddEvent(
net::NetLog::TYPE_DOWNLOAD_ITEM_CANCELED,
- base::Bind(&download_net_logs::ItemCanceledCallback,
- received_bytes_, &hash_state_));
+ base::Bind(&ItemCanceledNetLogCallback, received_bytes_,
+ &hash_state_));
break;
default:
break;
@@ -1396,7 +1377,7 @@ void DownloadItemImpl::TransitionTo(DownloadInternalState new_state) {
bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE);
}
-void DownloadItemImpl::SetDangerType(content::DownloadDangerType danger_type) {
+void DownloadItemImpl::SetDangerType(DownloadDangerType danger_type) {
danger_type_ = danger_type;
// Notify observers if the safety state has changed as a result of the new
// danger type.
@@ -1406,8 +1387,8 @@ void DownloadItemImpl::SetDangerType(content::DownloadDangerType danger_type) {
safety_state_ = updated_value;
bound_net_log_.AddEvent(
net::NetLog::TYPE_DOWNLOAD_ITEM_SAFETY_STATE_UPDATED,
- base::Bind(&download_net_logs::ItemCheckedCallback,
- GetDangerType(), GetSafetyState()));
+ base::Bind(&ItemCheckedNetLogCallback, GetDangerType(),
+ GetSafetyState()));
}
}
@@ -1421,8 +1402,7 @@ void DownloadItemImpl::SetFullPath(const FilePath& new_path) {
bound_net_log_.AddEvent(
net::NetLog::TYPE_DOWNLOAD_ITEM_RENAMED,
- base::Bind(&download_net_logs::ItemRenamedCallback,
- &current_path_, &new_path));
+ base::Bind(&ItemRenamedNetLogCallback, &current_path_, &new_path));
}
// static
@@ -1482,3 +1462,5 @@ const char* DownloadItemImpl::DebugDownloadStateString(
return "unknown";
};
}
+
+} // namespace content
diff --git a/content/browser/download/download_item_impl.h b/content/browser/download/download_item_impl.h
index 4324289..c49677c 100644
--- a/content/browser/download/download_item_impl.h
+++ b/content/browser/download/download_item_impl.h
@@ -24,16 +24,14 @@
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
-class DownloadItemImplDelegate;
-
namespace content {
class DownloadFile;
-}
+class DownloadItemImplDelegate;
// See download_item.h for usage.
class CONTENT_EXPORT DownloadItemImpl
- : public content::DownloadItem,
- public content::DownloadDestinationObserver {
+ : public DownloadItem,
+ public DownloadDestinationObserver {
public:
// Note that it is the responsibility of the caller to ensure that a
// DownloadItemImplDelegate passed to a DownloadItemImpl constructor
@@ -42,8 +40,8 @@ class CONTENT_EXPORT DownloadItemImpl
// Constructing from persistent store:
// |bound_net_log| is constructed externally for our use.
DownloadItemImpl(DownloadItemImplDelegate* delegate,
- content::DownloadId download_id,
- const content::DownloadPersistentStoreInfo& info,
+ DownloadId download_id,
+ const DownloadPersistentStoreInfo& info,
const net::BoundNetLog& bound_net_log);
// Constructing for a regular download.
@@ -58,7 +56,7 @@ class CONTENT_EXPORT DownloadItemImpl
DownloadItemImpl(DownloadItemImplDelegate* delegate,
const FilePath& path,
const GURL& url,
- content::DownloadId download_id,
+ DownloadId download_id,
const std::string& mime_type,
const net::BoundNetLog& bound_net_log);
@@ -76,10 +74,10 @@ class CONTENT_EXPORT DownloadItemImpl
virtual void OpenDownload() OVERRIDE;
virtual void ShowDownloadInShell() OVERRIDE;
virtual int32 GetId() const OVERRIDE;
- virtual content::DownloadId GetGlobalId() const OVERRIDE;
+ virtual DownloadId GetGlobalId() const OVERRIDE;
virtual int64 GetDbHandle() const OVERRIDE;
virtual DownloadState GetState() const OVERRIDE;
- virtual content::DownloadInterruptReason GetLastReason() const OVERRIDE;
+ virtual DownloadInterruptReason GetLastReason() const OVERRIDE;
virtual bool IsPaused() const OVERRIDE;
virtual bool IsTemporary() const OVERRIDE;
virtual bool IsPersisted() const OVERRIDE;
@@ -98,7 +96,7 @@ class CONTENT_EXPORT DownloadItemImpl
virtual std::string GetOriginalMimeType() const OVERRIDE;
virtual std::string GetRemoteAddress() const OVERRIDE;
virtual bool HasUserGesture() const OVERRIDE;
- virtual content::PageTransition GetTransitionType() const OVERRIDE;
+ virtual PageTransition GetTransitionType() const OVERRIDE;
virtual const std::string& GetLastModifiedTime() const OVERRIDE;
virtual const std::string& GetETag() const OVERRIDE;
virtual const FilePath& GetFullPath() const OVERRIDE;
@@ -112,7 +110,7 @@ class CONTENT_EXPORT DownloadItemImpl
virtual bool GetFileExternallyRemoved() const OVERRIDE;
virtual SafetyState GetSafetyState() const OVERRIDE;
virtual bool IsDangerous() const OVERRIDE;
- virtual content::DownloadDangerType GetDangerType() const OVERRIDE;
+ virtual DownloadDangerType GetDangerType() const OVERRIDE;
virtual bool TimeRemaining(base::TimeDelta* remaining) const OVERRIDE;
virtual int64 CurrentSpeed() const OVERRIDE;
virtual int PercentComplete() const OVERRIDE;
@@ -127,13 +125,11 @@ class CONTENT_EXPORT DownloadItemImpl
virtual bool GetOpenWhenComplete() const OVERRIDE;
virtual bool GetAutoOpened() OVERRIDE;
virtual bool GetOpened() const OVERRIDE;
- virtual content::DownloadPersistentStoreInfo
- GetPersistentStoreInfo() const OVERRIDE;
- virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
- virtual content::WebContents* GetWebContents() const OVERRIDE;
+ virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const OVERRIDE;
+ virtual BrowserContext* GetBrowserContext() const OVERRIDE;
+ virtual WebContents* GetWebContents() const OVERRIDE;
virtual void DelayedDownloadOpened(bool auto_opened) OVERRIDE;
- virtual void OnContentCheckCompleted(
- content::DownloadDangerType danger_type) OVERRIDE;
+ virtual void OnContentCheckCompleted(DownloadDangerType danger_type) OVERRIDE;
virtual void SetOpenWhenComplete(bool open) OVERRIDE;
virtual void SetIsTemporary(bool temporary) OVERRIDE;
virtual void SetOpened(bool opened) OVERRIDE;
@@ -151,7 +147,7 @@ class CONTENT_EXPORT DownloadItemImpl
// these other than Start() can be made private.
// Start the download
- virtual void Start(scoped_ptr<content::DownloadFile> download_file);
+ virtual void Start(scoped_ptr<DownloadFile> download_file);
// If all pre-requisites have been met, complete download processing, i.e. do
// internal cleanup, file rename, and potentially auto-open. (Dangerous
@@ -169,12 +165,11 @@ class CONTENT_EXPORT DownloadItemImpl
virtual void OnDownloadedFileRemoved();
// Indicate that an error has occurred on the download.
- virtual void Interrupt(content::DownloadInterruptReason reason);
+ virtual void Interrupt(DownloadInterruptReason reason);
// Provide a weak pointer reference to a DownloadDestinationObserver
// for use by download destinations.
- base::WeakPtr<content::DownloadDestinationObserver>
- DestinationObserverAsWeakPtr();
+ base::WeakPtr<DownloadDestinationObserver> DestinationObserverAsWeakPtr();
// For dispatching on whether we're dealing with a SavePackage download.
virtual bool IsSavePackageDownload() const;
@@ -238,8 +233,7 @@ class CONTENT_EXPORT DownloadItemImpl
virtual void DestinationUpdate(int64 bytes_so_far,
int64 bytes_per_sec,
const std::string& hash_state) OVERRIDE;
- virtual void DestinationError(
- content::DownloadInterruptReason reason) OVERRIDE;
+ virtual void DestinationError(DownloadInterruptReason reason) OVERRIDE;
virtual void DestinationCompleted(const std::string& final_hash) OVERRIDE;
// Normal progression of a download ------------------------------------------
@@ -252,7 +246,7 @@ class CONTENT_EXPORT DownloadItemImpl
// downloads and false for downloads from the history.
// |download_type| indicates to the net log system what kind of download
// this is.
- void Init(bool active, download_net_logs::DownloadType download_type);
+ void Init(bool active, DownloadType download_type);
// Called when the target path has been determined. |target_path| is the
// suggested target path. |disposition| indicates how the target path should
@@ -262,15 +256,14 @@ class CONTENT_EXPORT DownloadItemImpl
virtual void OnDownloadTargetDetermined(
const FilePath& target_path,
TargetDisposition disposition,
- content::DownloadDangerType danger_type,
+ DownloadDangerType danger_type,
const FilePath& intermediate_path);
// Callback from file thread when we initialize the DownloadFile.
- void OnDownloadFileInitialized(
- content::DownloadInterruptReason result);
+ void OnDownloadFileInitialized(DownloadInterruptReason result);
void OnDownloadRenamedToIntermediateName(
- content::DownloadInterruptReason reason, const FilePath& full_path);
+ DownloadInterruptReason reason, const FilePath& full_path);
// Called when the download is ready to complete.
// This may perform final rename if necessary and will eventually call
@@ -281,7 +274,7 @@ class CONTENT_EXPORT DownloadItemImpl
// the download.
void ReadyForDownloadCompletionDone();
- void OnDownloadRenamedToFinalName(content::DownloadInterruptReason reason,
+ void OnDownloadRenamedToFinalName(DownloadInterruptReason reason,
const FilePath& full_path);
void ReleaseDownloadFile();
@@ -308,7 +301,7 @@ class CONTENT_EXPORT DownloadItemImpl
void TransitionTo(DownloadInternalState new_state);
// Set the |danger_type_| and invoke obserers if necessary.
- void SetDangerType(content::DownloadDangerType danger_type);
+ void SetDangerType(DownloadDangerType danger_type);
void SetFullPath(const FilePath& new_path);
@@ -330,7 +323,7 @@ class CONTENT_EXPORT DownloadItemImpl
scoped_ptr<DownloadRequestHandleInterface> request_handle_;
// Download ID assigned by DownloadResourceHandler.
- content::DownloadId download_id_;
+ DownloadId download_id_;
// Display name for the download. If this is empty, then the display name is
// considered to be |target_path_.BaseName()|.
@@ -366,7 +359,7 @@ class CONTENT_EXPORT DownloadItemImpl
FilePath forced_file_path_;
// Page transition that triggerred the download.
- content::PageTransition transition_type_;
+ PageTransition transition_type_;
// Whether the download was triggered with a user gesture.
bool has_user_gesture_;
@@ -412,7 +405,7 @@ class CONTENT_EXPORT DownloadItemImpl
std::string etag_;
// Last reason.
- content::DownloadInterruptReason last_reason_;
+ DownloadInterruptReason last_reason_;
// Start time for recording statistics.
base::TimeTicks start_tick_;
@@ -421,7 +414,7 @@ class CONTENT_EXPORT DownloadItemImpl
DownloadInternalState state_;
// Current danger type for the download.
- content::DownloadDangerType danger_type_;
+ DownloadDangerType danger_type_;
// The views of this item in the download shelf and download contents.
ObserverList<Observer> observers_;
@@ -480,7 +473,7 @@ class CONTENT_EXPORT DownloadItemImpl
// pointer may only be used or destroyed on the FILE thread.
// This pointer will be non-null only while the DownloadItem is in
// the IN_PROGRESS state.
- scoped_ptr<content::DownloadFile> download_file_;
+ scoped_ptr<DownloadFile> download_file_;
// Net log to use for this download.
const net::BoundNetLog bound_net_log_;
@@ -490,4 +483,6 @@ class CONTENT_EXPORT DownloadItemImpl
DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_
diff --git a/content/browser/download/download_item_impl_delegate.cc b/content/browser/download/download_item_impl_delegate.cc
index c727ea5..070dec9 100644
--- a/content/browser/download/download_item_impl_delegate.cc
+++ b/content/browser/download/download_item_impl_delegate.cc
@@ -7,6 +7,8 @@
#include "base/logging.h"
#include "content/browser/download/download_item_impl.h"
+namespace content {
+
// Infrastructure in DownloadItemImplDelegate to assert invariant that
// delegate always outlives all attached DownloadItemImpls.
DownloadItemImplDelegate::DownloadItemImplDelegate()
@@ -30,8 +32,8 @@ void DownloadItemImplDelegate::DetermineDownloadTarget(
// TODO(rdsmith/asanka): Do something useful if forced file path is null.
FilePath target_path(download->GetForcedFilePath());
callback.Run(target_path,
- content::DownloadItem::TARGET_DISPOSITION_OVERWRITE,
- content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
+ DownloadItem::TARGET_DISPOSITION_OVERWRITE,
+ DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
target_path);
}
@@ -53,7 +55,7 @@ bool DownloadItemImplDelegate::ShouldOpenFileBasedOnExtension(
void DownloadItemImplDelegate::CheckForFileRemoval(
DownloadItemImpl* download_item) {}
-content::BrowserContext* DownloadItemImplDelegate::GetBrowserContext() const {
+BrowserContext* DownloadItemImplDelegate::GetBrowserContext() const {
return NULL;
}
@@ -79,3 +81,5 @@ void DownloadItemImplDelegate::DownloadRenamedToFinalName(
void DownloadItemImplDelegate::AssertStateConsistent(
DownloadItemImpl* download) const {}
+
+} // namespace content
diff --git a/content/browser/download/download_item_impl_delegate.h b/content/browser/download/download_item_impl_delegate.h
index d06aad4..efc2326 100644
--- a/content/browser/download/download_item_impl_delegate.h
+++ b/content/browser/download/download_item_impl_delegate.h
@@ -11,12 +11,10 @@
#include "content/public/browser/download_danger_type.h"
#include "content/public/browser/download_item.h"
+namespace content {
class DownloadFileManager;
class DownloadItemImpl;
-
-namespace content {
class BrowserContext;
-}
// Delegate for operations that a DownloadItemImpl can't do for itself.
// The base implementation of this class does nothing (returning false
@@ -26,8 +24,8 @@ class CONTENT_EXPORT DownloadItemImplDelegate {
public:
typedef base::Callback<void(
const FilePath&, // Target path
- content::DownloadItem::TargetDisposition, // overwrite/uniquify target
- content::DownloadDangerType,
+ DownloadItem::TargetDisposition, // overwrite/uniquify target
+ DownloadDangerType,
const FilePath& // Intermediate file path
)> DownloadTargetCallback;
@@ -65,7 +63,7 @@ class CONTENT_EXPORT DownloadItemImplDelegate {
virtual void CheckForFileRemoval(DownloadItemImpl* download_item);
// For contextual issues like language and prefs.
- virtual content::BrowserContext* GetBrowserContext() const;
+ virtual BrowserContext* GetBrowserContext() const;
// Get the DownloadFileManager to use for this download.
virtual DownloadFileManager* GetDownloadFileManager();
@@ -93,4 +91,6 @@ class CONTENT_EXPORT DownloadItemImplDelegate {
DISALLOW_COPY_AND_ASSIGN(DownloadItemImplDelegate);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_
diff --git a/content/browser/download/download_item_impl_unittest.cc b/content/browser/download/download_item_impl_unittest.cc
index b1fe883..bedab09 100644
--- a/content/browser/download/download_item_impl_unittest.cc
+++ b/content/browser/download/download_item_impl_unittest.cc
@@ -20,12 +20,6 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-using content::BrowserThread;
-using content::DownloadId;
-using content::DownloadItem;
-using content::DownloadManager;
-using content::MockDownloadItem;
-using content::WebContents;
using ::testing::_;
using ::testing::AllOf;
using ::testing::Property;
@@ -33,6 +27,7 @@ using ::testing::Return;
using ::testing::SaveArg;
using ::testing::StrictMock;
+namespace content {
DownloadId::Domain kValidDownloadItemIdDomain = "valid DownloadId::Domain";
namespace {
@@ -43,7 +38,7 @@ class MockDelegate : public DownloadItemImplDelegate {
MOCK_METHOD1(ShouldOpenDownload, bool(DownloadItemImpl* download));
MOCK_METHOD1(ShouldOpenFileBasedOnExtension, bool(const FilePath& path));
MOCK_METHOD1(CheckForFileRemoval, void(DownloadItemImpl* download));
- MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*());
+ MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*());
MOCK_METHOD1(UpdatePersistence, void(DownloadItemImpl* download));
MOCK_METHOD1(DownloadStopped, void(DownloadItemImpl* download));
MOCK_METHOD1(DownloadCompleted, void(DownloadItemImpl* download));
@@ -78,7 +73,7 @@ class MockRequestHandle : public DownloadRequestHandleInterface {
ACTION_P(ScheduleRenameCallback, new_path) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- base::Bind(arg2, content::DOWNLOAD_INTERRUPT_REASON_NONE, new_path));
+ base::Bind(arg2, DOWNLOAD_INTERRUPT_REASON_NONE, new_path));
}
// Schedules a task to invoke the input closure on
@@ -180,8 +175,7 @@ class DownloadItemTest : public testing::Test {
info_.reset(new DownloadCreateInfo());
static int next_id;
- info_->download_id =
- content::DownloadId(kValidDownloadItemIdDomain, ++next_id);
+ info_->download_id = DownloadId(kValidDownloadItemIdDomain, ++next_id);
info_->prompt_user_for_save_location = false;
info_->url_chain.push_back(GURL());
info_->state = state;
@@ -200,7 +194,7 @@ class DownloadItemTest : public testing::Test {
DownloadItemImpl* item,
DownloadItemImplDelegate::DownloadTargetCallback *callback) {
MockDownloadFile* mock_download_file(new StrictMock<MockDownloadFile>);
- scoped_ptr<content::DownloadFile> download_file(mock_download_file);
+ scoped_ptr<DownloadFile> download_file(mock_download_file);
EXPECT_CALL(*mock_download_file, Initialize(_));
if (callback) {
// Save the callback.
@@ -224,7 +218,7 @@ class DownloadItemTest : public testing::Test {
// Cleanup a download item (specifically get rid of the DownloadFile on it).
// The item must be in the IN_PROGRESS state.
void CleanupItem(DownloadItemImpl* item, MockDownloadFile* download_file) {
- EXPECT_EQ(content::DownloadItem::IN_PROGRESS, item->GetState());
+ EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState());
EXPECT_CALL(*download_file, Cancel());
EXPECT_CALL(delegate_, DownloadStopped(item));
@@ -248,8 +242,8 @@ class DownloadItemTest : public testing::Test {
private:
MessageLoopForUI loop_;
- content::TestBrowserThread ui_thread_; // UI thread
- content::TestBrowserThread file_thread_; // FILE thread
+ TestBrowserThread ui_thread_; // UI thread
+ TestBrowserThread file_thread_; // FILE thread
testing::NiceMock<MockDelegate> delegate_;
std::set<DownloadItem*> allocated_downloads_;
};
@@ -325,7 +319,7 @@ TEST_F(DownloadItemTest, NotificationAfterInterrupted) {
EXPECT_CALL(*download_file, Cancel());
MockObserver observer(item);
- item->Interrupt(content::DOWNLOAD_INTERRUPT_REASON_NONE);
+ item->Interrupt(DOWNLOAD_INTERRUPT_REASON_NONE);
ASSERT_TRUE(observer.CheckUpdated());
}
@@ -365,8 +359,7 @@ TEST_F(DownloadItemTest, NotificationAfterOnContentCheckCompleted) {
safe_item->OnAllDataSaved("");
EXPECT_TRUE(safe_observer.CheckUpdated());
- safe_item->OnContentCheckCompleted(
- content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
+ safe_item->OnContentCheckCompleted(DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
EXPECT_TRUE(safe_observer.CheckUpdated());
// Setting to unsafe url or unsafe file should trigger a notification.
@@ -376,8 +369,7 @@ TEST_F(DownloadItemTest, NotificationAfterOnContentCheckCompleted) {
unsafeurl_item->OnAllDataSaved("");
EXPECT_TRUE(unsafeurl_observer.CheckUpdated());
- unsafeurl_item->OnContentCheckCompleted(
- content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL);
+ unsafeurl_item->OnContentCheckCompleted(DOWNLOAD_DANGER_TYPE_DANGEROUS_URL);
EXPECT_TRUE(unsafeurl_observer.CheckUpdated());
unsafeurl_item->DangerousDownloadValidated();
@@ -389,8 +381,7 @@ TEST_F(DownloadItemTest, NotificationAfterOnContentCheckCompleted) {
unsafefile_item->OnAllDataSaved("");
EXPECT_TRUE(unsafefile_observer.CheckUpdated());
- unsafefile_item->OnContentCheckCompleted(
- content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE);
+ unsafefile_item->OnContentCheckCompleted(DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE);
EXPECT_TRUE(unsafefile_observer.CheckUpdated());
unsafefile_item->DangerousDownloadValidated();
@@ -417,7 +408,7 @@ TEST_F(DownloadItemTest, NotificationAfterOnDownloadTargetDetermined) {
// Currently, a notification would be generated if the danger type is anything
// other than NOT_DANGEROUS.
callback.Run(target_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
- content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path);
+ DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path);
EXPECT_FALSE(observer.CheckUpdated());
RunAllPendingInMessageLoops();
EXPECT_TRUE(observer.CheckUpdated());
@@ -449,7 +440,7 @@ TEST_F(DownloadItemTest, DisplayName) {
EXPECT_CALL(*download_file, Rename(_, false, _))
.WillOnce(ScheduleRenameCallback(intermediate_path));
callback.Run(target_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
- content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path);
+ DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path);
RunAllPendingInMessageLoops();
EXPECT_EQ(FILE_PATH_LITERAL("foo.bar"),
item->GetFileNameToReportUser().value());
@@ -462,7 +453,7 @@ TEST_F(DownloadItemTest, DisplayName) {
// Test to make sure that Start method calls DF initialize properly.
TEST_F(DownloadItemTest, Start) {
MockDownloadFile* mock_download_file(new MockDownloadFile);
- scoped_ptr<content::DownloadFile> download_file(mock_download_file);
+ scoped_ptr<DownloadFile> download_file(mock_download_file);
DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
EXPECT_CALL(*mock_download_file, Initialize(_));
item->Start(download_file.Pass());
@@ -495,7 +486,7 @@ TEST_F(DownloadItemTest, CallbackAfterRename) {
Property(&DownloadItem::GetFullPath,
new_intermediate_path))));
callback.Run(final_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
- content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path);
+ DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path);
RunAllPendingInMessageLoops();
// All the callbacks should have happened by now.
::testing::Mock::VerifyAndClearExpectations(download_file);
@@ -529,8 +520,8 @@ TEST_F(DownloadItemTest, Interrupted) {
DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item, NULL);
- const content::DownloadInterruptReason reason(
- content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED);
+ const DownloadInterruptReason reason(
+ DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED);
// Confirm interrupt sets state properly.
EXPECT_CALL(*download_file, Cancel());
@@ -542,8 +533,7 @@ TEST_F(DownloadItemTest, Interrupted) {
// Cancel should result in no change.
item->Cancel(true);
EXPECT_EQ(DownloadItem::INTERRUPTED, item->GetState());
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED,
- item->GetLastReason());
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_USER_CANCELED, item->GetLastReason());
}
TEST_F(DownloadItemTest, Canceled) {
@@ -567,7 +557,7 @@ TEST_F(DownloadItemTest, FileRemoved) {
TEST_F(DownloadItemTest, DestinationUpdate) {
DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
- base::WeakPtr<content::DownloadDestinationObserver> as_observer(
+ base::WeakPtr<DownloadDestinationObserver> as_observer(
item->DestinationObserverAsWeakPtr());
MockObserver observer(item);
@@ -597,32 +587,32 @@ TEST_F(DownloadItemTest, DestinationUpdate) {
TEST_F(DownloadItemTest, DestinationError) {
DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item, NULL);
- base::WeakPtr<content::DownloadDestinationObserver> as_observer(
+ base::WeakPtr<DownloadDestinationObserver> as_observer(
item->DestinationObserverAsWeakPtr());
MockObserver observer(item);
- EXPECT_EQ(content::DownloadItem::IN_PROGRESS, item->GetState());
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE, item->GetLastReason());
+ EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState());
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE, item->GetLastReason());
EXPECT_FALSE(observer.CheckUpdated());
EXPECT_CALL(*mock_delegate(), DownloadStopped(item));
EXPECT_CALL(*download_file, Cancel());
as_observer->DestinationError(
- content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED);
+ DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED);
::testing::Mock::VerifyAndClearExpectations(mock_delegate());
EXPECT_TRUE(observer.CheckUpdated());
- EXPECT_EQ(content::DownloadItem::INTERRUPTED, item->GetState());
- EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED,
+ EXPECT_EQ(DownloadItem::INTERRUPTED, item->GetState());
+ EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED,
item->GetLastReason());
}
TEST_F(DownloadItemTest, DestinationCompleted) {
DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
- base::WeakPtr<content::DownloadDestinationObserver> as_observer(
+ base::WeakPtr<DownloadDestinationObserver> as_observer(
item->DestinationObserverAsWeakPtr());
MockObserver observer(item);
- EXPECT_EQ(content::DownloadItem::IN_PROGRESS, item->GetState());
+ EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState());
EXPECT_EQ("", item->GetHash());
EXPECT_EQ("", item->GetHashState());
EXPECT_FALSE(item->AllDataSaved());
@@ -631,14 +621,14 @@ TEST_F(DownloadItemTest, DestinationCompleted) {
as_observer->DestinationUpdate(10, 20, "deadbeef");
EXPECT_TRUE(observer.CheckUpdated());
EXPECT_FALSE(observer.CheckUpdated()); // Confirm reset.
- EXPECT_EQ(content::DownloadItem::IN_PROGRESS, item->GetState());
+ EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState());
EXPECT_EQ("", item->GetHash());
EXPECT_EQ("deadbeef", item->GetHashState());
EXPECT_FALSE(item->AllDataSaved());
as_observer->DestinationCompleted("livebeef");
::testing::Mock::VerifyAndClearExpectations(mock_delegate());
- EXPECT_EQ(content::DownloadItem::IN_PROGRESS, item->GetState());
+ EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState());
EXPECT_TRUE(observer.CheckUpdated());
EXPECT_EQ("livebeef", item->GetHash());
EXPECT_EQ("", item->GetHashState());
@@ -648,3 +638,5 @@ TEST_F(DownloadItemTest, DestinationCompleted) {
TEST(MockDownloadItem, Compiles) {
MockDownloadItem mock_item;
}
+
+} // namespace content
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc
index 05c3ce3..b55057d 100644
--- a/content/browser/download/download_manager_impl.cc
+++ b/content/browser/download/download_manager_impl.cc
@@ -45,16 +45,10 @@
#include "net/url_request/url_request_context.h"
#include "webkit/glue/webkit_glue.h"
-using content::BrowserThread;
-using content::DownloadId;
-using content::DownloadItem;
-using content::DownloadPersistentStoreInfo;
-using content::ResourceDispatcherHostImpl;
-using content::WebContents;
-
+namespace content {
namespace {
-void BeginDownload(scoped_ptr<content::DownloadUrlParameters> params) {
+void BeginDownload(scoped_ptr<DownloadUrlParameters> params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and
// DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so
@@ -81,7 +75,7 @@ void BeginDownload(scoped_ptr<content::DownloadUrlParameters> params) {
upload_data->set_identifier(params->post_id());
request->set_upload(upload_data);
}
- for (content::DownloadUrlParameters::RequestHeadersType::const_iterator iter
+ for (DownloadUrlParameters::RequestHeadersType::const_iterator iter
= params->request_headers_begin();
iter != params->request_headers_end();
++iter) {
@@ -125,20 +119,20 @@ class MapValueIteratorAdapter {
void EnsureNoPendingDownloadJobsOnFile(bool* result) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- *result = (content::DownloadFile::GetNumberOfDownloadFiles() == 0);
+ *result = (DownloadFile::GetNumberOfDownloadFiles() == 0);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure());
}
-class DownloadItemFactoryImpl : public content::DownloadItemFactory {
+class DownloadItemFactoryImpl : public DownloadItemFactory {
public:
DownloadItemFactoryImpl() {}
virtual ~DownloadItemFactoryImpl() {}
virtual DownloadItemImpl* CreatePersistedItem(
DownloadItemImplDelegate* delegate,
- content::DownloadId download_id,
- const content::DownloadPersistentStoreInfo& info,
+ DownloadId download_id,
+ const DownloadPersistentStoreInfo& info,
const net::BoundNetLog& bound_net_log) OVERRIDE {
return new DownloadItemImpl(delegate, download_id, info, bound_net_log);
}
@@ -156,7 +150,7 @@ class DownloadItemFactoryImpl : public content::DownloadItemFactory {
DownloadItemImplDelegate* delegate,
const FilePath& path,
const GURL& url,
- content::DownloadId download_id,
+ DownloadId download_id,
const std::string& mime_type,
const net::BoundNetLog& bound_net_log) OVERRIDE {
return new DownloadItemImpl(delegate, path, url, download_id,
@@ -169,7 +163,7 @@ class DownloadItemFactoryImpl : public content::DownloadItemFactory {
DownloadManagerImpl::DownloadManagerImpl(
net::NetLog* net_log)
: item_factory_(new DownloadItemFactoryImpl()),
- file_factory_(new content::DownloadFileFactory()),
+ file_factory_(new DownloadFileFactory()),
history_size_(0),
shutdown_needed_(false),
browser_context_(NULL),
@@ -205,7 +199,7 @@ void DownloadManagerImpl::DetermineDownloadTarget(
// TODO(asanka): Determine a useful path if |target_path| is empty.
callback.Run(target_path,
DownloadItem::TARGET_DISPOSITION_OVERWRITE,
- content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
+ DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
target_path);
}
}
@@ -234,12 +228,11 @@ bool DownloadManagerImpl::ShouldOpenDownload(DownloadItemImpl* item) {
return delegate_->ShouldOpenDownload(item);
}
-void DownloadManagerImpl::SetDelegate(
- content::DownloadManagerDelegate* delegate) {
+void DownloadManagerImpl::SetDelegate(DownloadManagerDelegate* delegate) {
delegate_ = delegate;
}
-content::DownloadManagerDelegate* DownloadManagerImpl::GetDelegate() const {
+DownloadManagerDelegate* DownloadManagerImpl::GetDelegate() const {
return delegate_;
}
@@ -303,7 +296,7 @@ void DownloadManagerImpl::Shutdown() {
delegate_ = NULL;
}
-bool DownloadManagerImpl::Init(content::BrowserContext* browser_context) {
+bool DownloadManagerImpl::Init(BrowserContext* browser_context) {
DCHECK(browser_context);
DCHECK(!shutdown_needed_) << "DownloadManager already initialized.";
shutdown_needed_ = true;
@@ -315,7 +308,7 @@ bool DownloadManagerImpl::Init(content::BrowserContext* browser_context) {
DownloadItem* DownloadManagerImpl::StartDownload(
scoped_ptr<DownloadCreateInfo> info,
- scoped_ptr<content::ByteStreamReader> stream) {
+ scoped_ptr<ByteStreamReader> stream) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
net::BoundNetLog bound_net_log =
@@ -334,7 +327,7 @@ DownloadItem* DownloadManagerImpl::StartDownload(
// no associated DownloadFile (history downloads, !IN_PROGRESS downloads)
DownloadItemImpl* download =
CreateDownloadItem(info.get(), bound_net_log);
- scoped_ptr<content::DownloadFile> download_file(
+ scoped_ptr<DownloadFile> download_file(
file_factory_->CreateFile(
info->save_info.Pass(), default_download_directory,
info->url(), info->referrer_url,
@@ -390,7 +383,7 @@ void DownloadManagerImpl::OnFileRemovalDetected(int32 download_id) {
downloads_[download_id]->OnDownloadedFileRemoved();
}
-content::BrowserContext* DownloadManagerImpl::GetBrowserContext() const {
+BrowserContext* DownloadManagerImpl::GetBrowserContext() const {
return browser_context_;
}
@@ -506,17 +499,16 @@ void DownloadManagerImpl::RemoveFromActiveList(DownloadItemImpl* download) {
}
void DownloadManagerImpl::SetDownloadItemFactoryForTesting(
- scoped_ptr<content::DownloadItemFactory> item_factory) {
+ scoped_ptr<DownloadItemFactory> item_factory) {
item_factory_ = item_factory.Pass();
}
void DownloadManagerImpl::SetDownloadFileFactoryForTesting(
- scoped_ptr<content::DownloadFileFactory> file_factory) {
+ scoped_ptr<DownloadFileFactory> file_factory) {
file_factory_ = file_factory.Pass();
}
-content::DownloadFileFactory*
-DownloadManagerImpl::GetDownloadFileFactoryForTesting() {
+DownloadFileFactory* DownloadManagerImpl::GetDownloadFileFactoryForTesting() {
return file_factory_.get();
}
@@ -587,12 +579,12 @@ int DownloadManagerImpl::RemoveDownloads(base::Time remove_begin) {
int DownloadManagerImpl::RemoveAllDownloads() {
// The null times make the date range unbounded.
int num_deleted = RemoveDownloadsBetween(base::Time(), base::Time());
- download_stats::RecordClearAllSize(num_deleted);
+ RecordClearAllSize(num_deleted);
return num_deleted;
}
void DownloadManagerImpl::DownloadUrl(
- scoped_ptr<content::DownloadUrlParameters> params) {
+ scoped_ptr<DownloadUrlParameters> params) {
if (params->post_id() >= 0) {
// Check this here so that the traceback is more useful.
DCHECK(params->prefer_cache());
@@ -647,7 +639,7 @@ void DownloadManagerImpl::AddDownloadItemToHistory(DownloadItemImpl* download,
download->SetDbHandle(db_handle);
download->SetIsPersisted();
- download_stats::RecordHistorySize(history_size_);
+ RecordHistorySize(history_size_);
// Not counting |download|.
++history_size_;
@@ -805,8 +797,7 @@ void DownloadManagerImpl::OnSavePageItemAddedToPersistentStore(
SavePageDownloadFinished(item);
}
-void DownloadManagerImpl::SavePageDownloadFinished(
- content::DownloadItem* download) {
+void DownloadManagerImpl::SavePageDownloadFinished(DownloadItem* download) {
if (download->IsPersisted()) {
if (delegate_)
delegate_->UpdateItemInPersistentStore(download);
@@ -824,7 +815,7 @@ void DownloadManagerImpl::DownloadOpened(DownloadItemImpl* download) {
!item->GetOpened())
++num_unopened;
}
- download_stats::RecordOpensOutstanding(num_unopened);
+ RecordOpensOutstanding(num_unopened);
}
void DownloadManagerImpl::DownloadRenamedToIntermediateName(
@@ -851,3 +842,5 @@ void DownloadManagerImpl::DownloadRenamedToFinalName(
download, download->GetFullPath());
}
}
+
+} // namespace content
diff --git a/content/browser/download/download_manager_impl.h b/content/browser/download/download_manager_impl.h
index be1a701..8f1b523 100644
--- a/content/browser/download/download_manager_impl.h
+++ b/content/browser/download/download_manager_impl.h
@@ -19,21 +19,18 @@
#include "content/common/content_export.h"
#include "content/public/browser/download_manager.h"
-class DownloadFileManager;
-class DownloadItemImpl;
-
-namespace content {
-class DownloadItemFactory;
-class DownloadFileFactory;
-}
-
namespace net {
class BoundNetLog;
}
-class CONTENT_EXPORT DownloadManagerImpl
- : public content::DownloadManager,
- private DownloadItemImplDelegate {
+namespace content {
+class DownloadFileFactory;
+class DownloadFileManager;
+class DownloadItemFactory;
+class DownloadItemImpl;
+
+class CONTENT_EXPORT DownloadManagerImpl : public DownloadManager,
+ private DownloadItemImplDelegate {
public:
// Caller guarantees that |net_log| will remain valid
// for the lifetime of DownloadManagerImpl (until Shutdown() is called).
@@ -48,46 +45,44 @@ class CONTENT_EXPORT DownloadManagerImpl
const FilePath& main_file_path,
const GURL& page_url,
const std::string& mime_type,
- content::DownloadItem::Observer* observer);
+ DownloadItem::Observer* observer);
- // content::DownloadManager functions.
- virtual void SetDelegate(content::DownloadManagerDelegate* delegate) OVERRIDE;
- virtual content::DownloadManagerDelegate* GetDelegate() const OVERRIDE;
+ // DownloadManager functions.
+ virtual void SetDelegate(DownloadManagerDelegate* delegate) OVERRIDE;
+ virtual DownloadManagerDelegate* GetDelegate() const OVERRIDE;
virtual void Shutdown() OVERRIDE;
virtual void GetAllDownloads(DownloadVector* result) OVERRIDE;
- virtual bool Init(content::BrowserContext* browser_context) OVERRIDE;
- virtual content::DownloadItem* StartDownload(
+ virtual bool Init(BrowserContext* browser_context) OVERRIDE;
+ virtual DownloadItem* StartDownload(
scoped_ptr<DownloadCreateInfo> info,
- scoped_ptr<content::ByteStreamReader> stream) OVERRIDE;
+ scoped_ptr<ByteStreamReader> stream) OVERRIDE;
virtual void CancelDownload(int32 download_id) OVERRIDE;
virtual int RemoveDownloadsBetween(base::Time remove_begin,
base::Time remove_end) OVERRIDE;
virtual int RemoveDownloads(base::Time remove_begin) OVERRIDE;
virtual int RemoveAllDownloads() OVERRIDE;
- virtual void DownloadUrl(
- scoped_ptr<content::DownloadUrlParameters> params) OVERRIDE;
+ virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> params) OVERRIDE;
virtual void AddObserver(Observer* observer) OVERRIDE;
virtual void RemoveObserver(Observer* observer) OVERRIDE;
virtual void OnPersistentStoreQueryComplete(
- std::vector<content::DownloadPersistentStoreInfo>* entries) OVERRIDE;
+ std::vector<DownloadPersistentStoreInfo>* entries) OVERRIDE;
virtual void OnItemAddedToPersistentStore(int32 download_id,
int64 db_handle) OVERRIDE;
virtual int InProgressCount() const OVERRIDE;
- virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
+ virtual BrowserContext* GetBrowserContext() const OVERRIDE;
virtual void CheckForHistoryFilesRemoval() OVERRIDE;
- virtual content::DownloadItem* GetDownload(int id) OVERRIDE;
- virtual void SavePageDownloadFinished(
- content::DownloadItem* download) OVERRIDE;
+ virtual DownloadItem* GetDownload(int id) OVERRIDE;
+ virtual void SavePageDownloadFinished(DownloadItem* download) OVERRIDE;
// For testing; specifically, accessed from TestFileErrorInjector.
void SetDownloadItemFactoryForTesting(
- scoped_ptr<content::DownloadItemFactory> item_factory);
+ scoped_ptr<DownloadItemFactory> item_factory);
void SetDownloadFileFactoryForTesting(
- scoped_ptr<content::DownloadFileFactory> file_factory);
- virtual content::DownloadFileFactory* GetDownloadFileFactoryForTesting();
+ scoped_ptr<DownloadFileFactory> file_factory);
+ virtual DownloadFileFactory* GetDownloadFileFactoryForTesting();
private:
- typedef std::set<content::DownloadItem*> DownloadSet;
+ typedef std::set<DownloadItem*> DownloadSet;
typedef base::hash_map<int32, DownloadItemImpl*> DownloadMap;
typedef std::vector<DownloadItemImpl*> DownloadItemImplVector;
@@ -107,7 +102,7 @@ class CONTENT_EXPORT DownloadManagerImpl
void ShowDownloadInBrowser(DownloadItemImpl* download);
// Get next download id.
- content::DownloadId GetNextId();
+ DownloadId GetNextId();
// Called on the FILE thread to check the existence of a downloaded file.
void CheckForFileRemovalOnFileThread(int32 download_id, const FilePath& path);
@@ -161,10 +156,10 @@ class CONTENT_EXPORT DownloadManagerImpl
virtual void AssertStateConsistent(DownloadItemImpl* download) const OVERRIDE;
// Factory for creation of downloads items.
- scoped_ptr<content::DownloadItemFactory> item_factory_;
+ scoped_ptr<DownloadItemFactory> item_factory_;
// Factory for the creation of download files.
- scoped_ptr<content::DownloadFileFactory> file_factory_;
+ scoped_ptr<DownloadFileFactory> file_factory_;
// |downloads_| is the owning set for all downloads known to the
// DownloadManager. This includes downloads started by the user in
@@ -199,14 +194,16 @@ class CONTENT_EXPORT DownloadManagerImpl
ObserverList<Observer> observers_;
// The current active browser context.
- content::BrowserContext* browser_context_;
+ BrowserContext* browser_context_;
// Allows an embedder to control behavior. Guaranteed to outlive this object.
- content::DownloadManagerDelegate* delegate_;
+ DownloadManagerDelegate* delegate_;
net::NetLog* net_log_;
DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_
diff --git a/content/browser/download/download_manager_impl_unittest.cc b/content/browser/download/download_manager_impl_unittest.cc
index 6b1538a..0886e98 100644
--- a/content/browser/download/download_manager_impl_unittest.cc
+++ b/content/browser/download/download_manager_impl_unittest.cc
@@ -47,14 +47,10 @@ using ::testing::ReturnRef;
using ::testing::SetArgPointee;
using ::testing::StrictMock;
using ::testing::_;
-using content::DownloadInterruptReason;
-using content::DownloadItem;
-using content::DownloadManager;
-using content::WebContents;
+
namespace content {
class ByteStreamReader;
-}
namespace {
@@ -69,16 +65,16 @@ class MockDownloadItemImpl : public DownloadItemImpl {
public:
// Use history constructor for minimal base object.
MockDownloadItemImpl(DownloadItemImplDelegate* delegate)
- : DownloadItemImpl(delegate, content::DownloadId(),
- content::DownloadPersistentStoreInfo(),
+ : DownloadItemImpl(delegate, DownloadId(),
+ DownloadPersistentStoreInfo(),
net::BoundNetLog()) {}
virtual ~MockDownloadItemImpl() {}
MOCK_METHOD4(OnDownloadTargetDetermined,
void(const FilePath&, TargetDisposition,
- content::DownloadDangerType, const FilePath&));
- MOCK_METHOD1(AddObserver, void(content::DownloadItem::Observer*));
- MOCK_METHOD1(RemoveObserver, void(content::DownloadItem::Observer*));
+ DownloadDangerType, const FilePath&));
+ MOCK_METHOD1(AddObserver, void(DownloadItem::Observer*));
+ MOCK_METHOD1(RemoveObserver, void(DownloadItem::Observer*));
MOCK_METHOD0(UpdateObservers, void());
MOCK_METHOD0(CanShowInFolder, bool());
MOCK_METHOD0(CanOpenDownload, bool());
@@ -94,11 +90,11 @@ class MockDownloadItemImpl : public DownloadItemImpl {
MOCK_METHOD0(OnDownloadedFileRemoved, void());
MOCK_METHOD0(MaybeCompleteDownload, void());
virtual void Start(
- scoped_ptr<content::DownloadFile> download_file) OVERRIDE {
+ scoped_ptr<DownloadFile> download_file) OVERRIDE {
MockStart(download_file.get());
}
- MOCK_METHOD1(MockStart, void(content::DownloadFile*));
+ MOCK_METHOD1(MockStart, void(DownloadFile*));
MOCK_METHOD1(Interrupt, void(DownloadInterruptReason));
MOCK_METHOD1(Delete, void(DeleteReason));
@@ -117,7 +113,7 @@ class MockDownloadItemImpl : public DownloadItemImpl {
MOCK_CONST_METHOD0(GetFullPath, const FilePath&());
MOCK_CONST_METHOD0(GetTargetFilePath, const FilePath&());
MOCK_CONST_METHOD0(GetTargetDisposition, TargetDisposition());
- MOCK_METHOD1(OnContentCheckCompleted, void(content::DownloadDangerType));
+ MOCK_METHOD1(OnContentCheckCompleted, void(DownloadDangerType));
MOCK_CONST_METHOD0(GetState, DownloadState());
MOCK_CONST_METHOD0(GetUrlChain, const std::vector<GURL>&());
MOCK_METHOD1(SetTotalBytes, void(int64));
@@ -135,25 +131,25 @@ class MockDownloadItemImpl : public DownloadItemImpl {
MOCK_CONST_METHOD0(GetHashState, const std::string&());
MOCK_CONST_METHOD0(GetHash, const std::string&());
MOCK_CONST_METHOD0(GetId, int32());
- MOCK_CONST_METHOD0(GetGlobalId, content::DownloadId());
+ MOCK_CONST_METHOD0(GetGlobalId, DownloadId());
MOCK_CONST_METHOD0(GetStartTime, base::Time());
MOCK_CONST_METHOD0(GetEndTime, base::Time());
MOCK_METHOD0(SetIsPersisted, void());
MOCK_CONST_METHOD0(IsPersisted, bool());
MOCK_METHOD1(SetDbHandle, void(int64));
MOCK_CONST_METHOD0(GetDbHandle, int64());
- MOCK_METHOD0(GetDownloadManager, content::DownloadManager*());
+ MOCK_METHOD0(GetDownloadManager, DownloadManager*());
MOCK_CONST_METHOD0(IsPaused, bool());
MOCK_CONST_METHOD0(GetOpenWhenComplete, bool());
MOCK_METHOD1(SetOpenWhenComplete, void(bool));
MOCK_CONST_METHOD0(GetFileExternallyRemoved, bool());
MOCK_CONST_METHOD0(GetSafetyState, SafetyState());
- MOCK_CONST_METHOD0(GetDangerType, content::DownloadDangerType());
+ MOCK_CONST_METHOD0(GetDangerType, DownloadDangerType());
MOCK_CONST_METHOD0(IsDangerous, bool());
MOCK_METHOD0(GetAutoOpened, bool());
MOCK_CONST_METHOD0(GetForcedFilePath, const FilePath&());
MOCK_CONST_METHOD0(HasUserGesture, bool());
- MOCK_CONST_METHOD0(GetTransitionType, content::PageTransition());
+ MOCK_CONST_METHOD0(GetTransitionType, PageTransition());
MOCK_CONST_METHOD0(IsTemporary, bool());
MOCK_METHOD1(SetIsTemporary, void(bool));
MOCK_METHOD1(SetOpened, void(bool));
@@ -161,10 +157,9 @@ class MockDownloadItemImpl : public DownloadItemImpl {
MOCK_CONST_METHOD0(GetLastModifiedTime, const std::string&());
MOCK_CONST_METHOD0(GetETag, const std::string&());
MOCK_CONST_METHOD0(GetLastReason, DownloadInterruptReason());
- MOCK_CONST_METHOD0(GetPersistentStoreInfo,
- content::DownloadPersistentStoreInfo());
- MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*());
- MOCK_CONST_METHOD0(GetWebContents, content::WebContents*());
+ MOCK_CONST_METHOD0(GetPersistentStoreInfo, DownloadPersistentStoreInfo());
+ MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*());
+ MOCK_CONST_METHOD0(GetWebContents, WebContents*());
MOCK_CONST_METHOD0(GetFileNameToReportUser, FilePath());
MOCK_METHOD1(SetDisplayName, void(const FilePath&));
MOCK_CONST_METHOD0(GetUserVerifiedFilePath, FilePath());
@@ -172,16 +167,16 @@ class MockDownloadItemImpl : public DownloadItemImpl {
MOCK_METHOD0(MockDownloadOpenForTesting, void());
};
-class MockDownloadManagerDelegate : public content::DownloadManagerDelegate {
+class MockDownloadManagerDelegate : public DownloadManagerDelegate {
public:
MockDownloadManagerDelegate();
virtual ~MockDownloadManagerDelegate();
MOCK_METHOD0(Shutdown, void());
- MOCK_METHOD0(GetNextId, content::DownloadId());
+ MOCK_METHOD0(GetNextId, DownloadId());
MOCK_METHOD2(DetermineDownloadTarget,
bool(DownloadItem* item,
- const content::DownloadTargetCallback&));
+ const DownloadTargetCallback&));
MOCK_METHOD0(GetAlternativeWebContentsToNotifyForDownload, WebContents*());
MOCK_METHOD1(ShouldOpenFileBasedOnExtension, bool(const FilePath&));
MOCK_METHOD2(ShouldCompleteDownload,
@@ -195,11 +190,11 @@ class MockDownloadManagerDelegate : public content::DownloadManagerDelegate {
MOCK_METHOD1(RemoveItemFromPersistentStore, void(DownloadItem*));
MOCK_METHOD2(RemoveItemsFromPersistentStoreBetween, void(
base::Time remove_begin, base::Time remove_end));
- MOCK_METHOD4(GetSaveDir, void(content::BrowserContext*,
+ MOCK_METHOD4(GetSaveDir, void(BrowserContext*,
FilePath*, FilePath*, bool*));
MOCK_METHOD5(ChooseSavePath, void(
WebContents*, const FilePath&, const FilePath::StringType&,
- bool, const content::SavePackagePathPickedCallback&));
+ bool, const SavePackagePathPickedCallback&));
};
MockDownloadManagerDelegate::MockDownloadManagerDelegate() {}
@@ -207,7 +202,7 @@ MockDownloadManagerDelegate::MockDownloadManagerDelegate() {}
MockDownloadManagerDelegate::~MockDownloadManagerDelegate() {}
class MockDownloadItemFactory
- : public content::DownloadItemFactory,
+ : public DownloadItemFactory,
public base::SupportsWeakPtr<MockDownloadItemFactory> {
public:
MockDownloadItemFactory();
@@ -231,8 +226,8 @@ class MockDownloadItemFactory
// Overridden methods from DownloadItemFactory.
virtual DownloadItemImpl* CreatePersistedItem(
DownloadItemImplDelegate* delegate,
- content::DownloadId download_id,
- const content::DownloadPersistentStoreInfo& info,
+ DownloadId download_id,
+ const DownloadPersistentStoreInfo& info,
const net::BoundNetLog& bound_net_log) OVERRIDE;
virtual DownloadItemImpl* CreateActiveItem(
DownloadItemImplDelegate* delegate,
@@ -243,7 +238,7 @@ class MockDownloadItemFactory
DownloadItemImplDelegate* delegate,
const FilePath& path,
const GURL& url,
- content::DownloadId download_id,
+ DownloadId download_id,
const std::string& mime_type,
const net::BoundNetLog& bound_net_log) OVERRIDE;
@@ -282,8 +277,8 @@ void MockDownloadItemFactory::RemoveItem(int id) {
DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem(
DownloadItemImplDelegate* delegate,
- content::DownloadId download_id,
- const content::DownloadPersistentStoreInfo& info,
+ DownloadId download_id,
+ const DownloadPersistentStoreInfo& info,
const net::BoundNetLog& bound_net_log) {
int local_id = download_id.local();
DCHECK(items_.find(local_id) == items_.end());
@@ -310,7 +305,7 @@ DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem(
EXPECT_CALL(*result, GetId())
.WillRepeatedly(Return(local_id));
EXPECT_CALL(*result, GetGlobalId())
- .WillRepeatedly(Return(content::DownloadId(delegate, local_id)));
+ .WillRepeatedly(Return(DownloadId(delegate, local_id)));
items_[local_id] = result;
// Active items are created and then immediately are called to start
@@ -324,7 +319,7 @@ DownloadItemImpl* MockDownloadItemFactory::CreateSavePageItem(
DownloadItemImplDelegate* delegate,
const FilePath& path,
const GURL& url,
- content::DownloadId download_id,
+ DownloadId download_id,
const std::string& mime_type,
const net::BoundNetLog& bound_net_log) {
int local_id = download_id.local();
@@ -340,38 +335,38 @@ DownloadItemImpl* MockDownloadItemFactory::CreateSavePageItem(
}
class MockDownloadFileFactory
- : public content::DownloadFileFactory,
+ : public DownloadFileFactory,
public base::SupportsWeakPtr<MockDownloadFileFactory> {
public:
MockDownloadFileFactory() {}
virtual ~MockDownloadFileFactory() {}
// Overridden method from DownloadFileFactory
- MOCK_METHOD9(MockCreateFile, content::DownloadFile*(
- const content::DownloadSaveInfo&,
+ MOCK_METHOD9(MockCreateFile, DownloadFile*(
+ const DownloadSaveInfo&,
const FilePath&,
const GURL&, const GURL&, int64, bool,
- content::ByteStreamReader*,
+ ByteStreamReader*,
const net::BoundNetLog&,
- base::WeakPtr<content::DownloadDestinationObserver>));
+ base::WeakPtr<DownloadDestinationObserver>));
- virtual content::DownloadFile* CreateFile(
- scoped_ptr<content::DownloadSaveInfo> save_info,
+ virtual DownloadFile* CreateFile(
+ scoped_ptr<DownloadSaveInfo> save_info,
const FilePath& default_download_directory,
const GURL& url,
const GURL& referrer_url,
int64 received_bytes,
bool calculate_hash,
- scoped_ptr<content::ByteStreamReader> stream,
+ scoped_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
- base::WeakPtr<content::DownloadDestinationObserver> observer) {
+ base::WeakPtr<DownloadDestinationObserver> observer) {
return MockCreateFile(*save_info.get(), default_download_directory, url,
referrer_url, received_bytes, calculate_hash,
stream.get(), bound_net_log, observer);
}
};
-class MockBrowserContext : public content::BrowserContext {
+class MockBrowserContext : public BrowserContext {
public:
MockBrowserContext() {}
~MockBrowserContext() {}
@@ -389,25 +384,25 @@ class MockBrowserContext : public content::BrowserContext {
net::URLRequestContextGetter*(int renderer_child_id));
MOCK_METHOD1(GetMediaRequestContextForStoragePartition,
net::URLRequestContextGetter*(const std::string& id));
- MOCK_METHOD0(GetResourceContext, content::ResourceContext*());
- MOCK_METHOD0(GetDownloadManagerDelegate, content::DownloadManagerDelegate*());
+ MOCK_METHOD0(GetResourceContext, ResourceContext*());
+ MOCK_METHOD0(GetDownloadManagerDelegate, DownloadManagerDelegate*());
MOCK_METHOD0(GetGeolocationPermissionContext,
- content::GeolocationPermissionContext* ());
+ GeolocationPermissionContext* ());
MOCK_METHOD0(GetSpeechRecognitionPreferences,
- content::SpeechRecognitionPreferences* ());
+ SpeechRecognitionPreferences* ());
MOCK_METHOD0(GetSpecialStoragePolicy, quota::SpecialStoragePolicy*());
};
-class MockDownloadManagerObserver : public content::DownloadManager::Observer {
+class MockDownloadManagerObserver : public DownloadManager::Observer {
public:
MockDownloadManagerObserver() {}
~MockDownloadManagerObserver() {}
MOCK_METHOD2(OnDownloadCreated, void(
- content::DownloadManager*, content::DownloadItem*));
- MOCK_METHOD1(ModelChanged, void(content::DownloadManager*));
- MOCK_METHOD1(ManagerGoingDown, void(content::DownloadManager*));
+ DownloadManager*, DownloadItem*));
+ MOCK_METHOD1(ModelChanged, void(DownloadManager*));
+ MOCK_METHOD1(ManagerGoingDown, void(DownloadManager*));
MOCK_METHOD2(SelectFileDialogDisplayed, void(
- content::DownloadManager*, int32));
+ DownloadManager*, int32));
};
} // namespace
@@ -418,8 +413,8 @@ class DownloadManagerTest : public testing::Test {
static const size_t kTestDataLen;
DownloadManagerTest()
- : ui_thread_(content::BrowserThread::UI, &message_loop_),
- file_thread_(content::BrowserThread::FILE, &message_loop_),
+ : ui_thread_(BrowserThread::UI, &message_loop_),
+ file_thread_(BrowserThread::FILE, &message_loop_),
next_download_id_(0) {
}
@@ -444,10 +439,10 @@ class DownloadManagerTest : public testing::Test {
download_manager_ = new DownloadManagerImpl(NULL);
download_manager_->SetDownloadItemFactoryForTesting(
- scoped_ptr<content::DownloadItemFactory>(
+ scoped_ptr<DownloadItemFactory>(
mock_download_item_factory_.get()).Pass());
download_manager_->SetDownloadFileFactoryForTesting(
- scoped_ptr<content::DownloadFileFactory>(
+ scoped_ptr<DownloadFileFactory>(
mock_download_file_factory_.get()).Pass());
observer_.reset(new MockDownloadManagerObserver());
EXPECT_CALL(GetMockObserver(), ModelChanged(download_manager_.get()))
@@ -461,7 +456,7 @@ class DownloadManagerTest : public testing::Test {
while (MockDownloadItemImpl*
item = mock_download_item_factory_->PopItem()) {
EXPECT_CALL(*item, GetSafetyState())
- .WillOnce(Return(content::DownloadItem::SAFE));
+ .WillOnce(Return(DownloadItem::SAFE));
EXPECT_CALL(*item, IsPartialDownload())
.WillOnce(Return(false));
}
@@ -488,7 +483,7 @@ class DownloadManagerTest : public testing::Test {
// null.
int id = next_download_id_;
++next_download_id_;
- info.download_id = content::DownloadId(kDownloadIdDomain, id);
+ info.download_id = DownloadId(kDownloadIdDomain, id);
info.request_handle = DownloadRequestHandle();
download_manager_->CreateDownloadItem(&info, net::BoundNetLog());
@@ -497,7 +492,7 @@ class DownloadManagerTest : public testing::Test {
// Satisfy expectation. If the item is created in StartDownload(),
// we call Start on it immediately, so we need to set that expectation
// in the factory.
- item.Start(scoped_ptr<content::DownloadFile>());
+ item.Start(scoped_ptr<DownloadFile>());
return item;
}
@@ -529,8 +524,8 @@ class DownloadManagerTest : public testing::Test {
void DownloadTargetDeterminedCallback(
const FilePath& target_path,
- content::DownloadItem::TargetDisposition disposition,
- content::DownloadDangerType danger_type,
+ DownloadItem::TargetDisposition disposition,
+ DownloadDangerType danger_type,
const FilePath& intermediate_path) {
callback_called_ = true;
target_path_ = target_path;
@@ -583,14 +578,14 @@ class DownloadManagerTest : public testing::Test {
// Target detetermined callback.
bool callback_called_;
FilePath target_path_;
- content::DownloadItem::TargetDisposition target_disposition_;
- content::DownloadDangerType danger_type_;
+ DownloadItem::TargetDisposition target_disposition_;
+ DownloadDangerType danger_type_;
FilePath intermediate_path_;
private:
MessageLoopForUI message_loop_;
- content::TestBrowserThread ui_thread_;
- content::TestBrowserThread file_thread_;
+ TestBrowserThread ui_thread_;
+ TestBrowserThread file_thread_;
base::WeakPtr<MockDownloadItemFactory> mock_download_item_factory_;
scoped_ptr<MockDownloadManagerDelegate> mock_download_manager_delegate_;
scoped_ptr<MockBrowserContext> mock_browser_context_;
@@ -603,7 +598,7 @@ class DownloadManagerTest : public testing::Test {
// Confirm the appropriate invocations occur when you start a download.
TEST_F(DownloadManagerTest, StartDownload) {
scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo);
- scoped_ptr<content::ByteStreamReader> stream;
+ scoped_ptr<ByteStreamReader> stream;
int32 local_id(5); // Random value
FilePath download_path(FILE_PATH_LITERAL("download/path"));
@@ -612,7 +607,7 @@ TEST_F(DownloadManagerTest, StartDownload) {
EXPECT_CALL(GetMockObserver(), OnDownloadCreated(download_manager_.get(), _))
.WillOnce(Return());
EXPECT_CALL(GetMockDownloadManagerDelegate(), GetNextId())
- .WillOnce(Return(content::DownloadId(this, local_id)));
+ .WillOnce(Return(DownloadId(this, local_id)));
// Doing nothing will set the default download directory to null.
EXPECT_CALL(GetMockDownloadManagerDelegate(), GetSaveDir(_, _, _, _));
@@ -656,9 +651,8 @@ TEST_F(DownloadManagerTest, DetermineDownloadTarget_False) {
DetermineDownloadTarget(&item);
EXPECT_TRUE(callback_called_);
EXPECT_EQ(path, target_path_);
- EXPECT_EQ(content::DownloadItem::TARGET_DISPOSITION_OVERWRITE,
- target_disposition_);
- EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, danger_type_);
+ EXPECT_EQ(DownloadItem::TARGET_DISPOSITION_OVERWRITE, target_disposition_);
+ EXPECT_EQ(DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, danger_type_);
EXPECT_EQ(path, intermediate_path_);
}
@@ -699,3 +693,5 @@ TEST_F(DownloadManagerTest, OnDownloadStopped_Persisted) {
DownloadStopped(&item);
}
+
+} // namespace content
diff --git a/content/browser/download/download_net_log_parameters.cc b/content/browser/download/download_net_log_parameters.cc
index c0d42cf..3dcfcfb 100644
--- a/content/browser/download/download_net_log_parameters.cc
+++ b/content/browser/download/download_net_log_parameters.cc
@@ -13,7 +13,7 @@
#include "googleurl/src/gurl.h"
#include "net/base/net_errors.h"
-namespace download_net_logs {
+namespace content {
namespace {
@@ -39,19 +39,19 @@ static const char* download_danger_names[] = {
COMPILE_ASSERT(ARRAYSIZE_UNSAFE(download_type_names) == SRC_SAVE_PAGE_AS + 1,
download_type_enum_has_changed);
COMPILE_ASSERT(ARRAYSIZE_UNSAFE(download_safety_names) ==
- content::DownloadItem::DANGEROUS_BUT_VALIDATED + 1,
+ DownloadItem::DANGEROUS_BUT_VALIDATED + 1,
downloaditem_safety_state_enum_has_changed);
COMPILE_ASSERT(ARRAYSIZE_UNSAFE(download_danger_names) ==
- content::DOWNLOAD_DANGER_TYPE_MAX,
+ DOWNLOAD_DANGER_TYPE_MAX,
download_danger_enum_has_changed);
} // namespace
-base::Value* ItemActivatedCallback(
- const content::DownloadItem* download_item,
+base::Value* ItemActivatedNetLogCallback(
+ const DownloadItem* download_item,
DownloadType download_type,
const std::string* file_name,
- net::NetLog::LogLevel /* log_level */) {
+ net::NetLog::LogLevel log_level) {
DictionaryValue* dict = new DictionaryValue();
dict->SetString("type", download_type_names[download_type]);
@@ -69,10 +69,10 @@ base::Value* ItemActivatedCallback(
return dict;
}
-base::Value* ItemCheckedCallback(
- content::DownloadDangerType danger_type,
- content::DownloadItem::SafetyState safety_state,
- net::NetLog::LogLevel /* log_level */) {
+base::Value* ItemCheckedNetLogCallback(
+ DownloadDangerType danger_type,
+ DownloadItem::SafetyState safety_state,
+ net::NetLog::LogLevel log_level) {
DictionaryValue* dict = new DictionaryValue();
dict->SetString("danger_type", download_danger_names[danger_type]);
@@ -81,9 +81,9 @@ base::Value* ItemCheckedCallback(
return dict;
}
-base::Value* ItemRenamedCallback(const FilePath* old_filename,
- const FilePath* new_filename,
- net::NetLog::LogLevel /* log_level */) {
+base::Value* ItemRenamedNetLogCallback(const FilePath* old_filename,
+ const FilePath* new_filename,
+ net::NetLog::LogLevel log_level) {
DictionaryValue* dict = new DictionaryValue();
dict->SetString("old_filename", old_filename->AsUTF8Unsafe());
@@ -92,10 +92,10 @@ base::Value* ItemRenamedCallback(const FilePath* old_filename,
return dict;
}
-base::Value* ItemInterruptedCallback(content::DownloadInterruptReason reason,
- int64 bytes_so_far,
- const std::string* hash_state,
- net::NetLog::LogLevel /* log_level */) {
+base::Value* ItemInterruptedNetLogCallback(DownloadInterruptReason reason,
+ int64 bytes_so_far,
+ const std::string* hash_state,
+ net::NetLog::LogLevel log_level) {
DictionaryValue* dict = new DictionaryValue();
dict->SetString("interrupt_reason", InterruptReasonDebugString(reason));
@@ -106,9 +106,9 @@ base::Value* ItemInterruptedCallback(content::DownloadInterruptReason reason,
return dict;
}
-base::Value* ItemCompletingCallback(int64 bytes_so_far,
- const std::string* final_hash,
- net::NetLog::LogLevel /* log_level */) {
+base::Value* ItemCompletingNetLogCallback(int64 bytes_so_far,
+ const std::string* final_hash,
+ net::NetLog::LogLevel log_level) {
DictionaryValue* dict = new DictionaryValue();
dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far));
@@ -118,8 +118,8 @@ base::Value* ItemCompletingCallback(int64 bytes_so_far,
return dict;
}
-base::Value* ItemFinishedCallback(bool auto_opened,
- net::NetLog::LogLevel /* log_level */) {
+base::Value* ItemFinishedNetLogCallback(bool auto_opened,
+ net::NetLog::LogLevel log_level) {
DictionaryValue* dict = new DictionaryValue();
dict->SetString("auto_opened", auto_opened ? "yes" : "no");
@@ -127,9 +127,9 @@ base::Value* ItemFinishedCallback(bool auto_opened,
return dict;
}
-base::Value* ItemCanceledCallback(int64 bytes_so_far,
- const std::string* hash_state,
- net::NetLog::LogLevel /* log_level */) {
+base::Value* ItemCanceledNetLogCallback(int64 bytes_so_far,
+ const std::string* hash_state,
+ net::NetLog::LogLevel log_level) {
DictionaryValue* dict = new DictionaryValue();
dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far));
@@ -139,9 +139,9 @@ base::Value* ItemCanceledCallback(int64 bytes_so_far,
return dict;
}
-base::Value* FileOpenedCallback(const FilePath* file_name,
- int64 start_offset,
- net::NetLog::LogLevel /* log_level */) {
+base::Value* FileOpenedNetLogCallback(const FilePath* file_name,
+ int64 start_offset,
+ net::NetLog::LogLevel log_level) {
DictionaryValue* dict = new DictionaryValue();
dict->SetString("file_name", file_name->AsUTF8Unsafe());
@@ -150,9 +150,9 @@ base::Value* FileOpenedCallback(const FilePath* file_name,
return dict;
}
-base::Value* FileStreamDrainedCallback(size_t stream_size,
- size_t num_buffers,
- net::NetLog::LogLevel /* log_level */) {
+base::Value* FileStreamDrainedNetLogCallback(size_t stream_size,
+ size_t num_buffers,
+ net::NetLog::LogLevel log_level) {
DictionaryValue* dict = new DictionaryValue();
dict->SetInteger("stream_size", static_cast<int>(stream_size));
@@ -161,9 +161,9 @@ base::Value* FileStreamDrainedCallback(size_t stream_size,
return dict;
}
-base::Value* FileRenamedCallback(const FilePath* old_filename,
- const FilePath* new_filename,
- net::NetLog::LogLevel /* log_level */) {
+base::Value* FileRenamedNetLogCallback(const FilePath* old_filename,
+ const FilePath* new_filename,
+ net::NetLog::LogLevel log_level) {
DictionaryValue* dict = new DictionaryValue();
dict->SetString("old_filename", old_filename->AsUTF8Unsafe());
@@ -172,9 +172,9 @@ base::Value* FileRenamedCallback(const FilePath* old_filename,
return dict;
}
-base::Value* FileErrorCallback(const char* operation,
- net::Error net_error,
- net::NetLog::LogLevel /* log_level */) {
+base::Value* FileErrorNetLogCallback(const char* operation,
+ net::Error net_error,
+ net::NetLog::LogLevel log_level) {
DictionaryValue* dict = new DictionaryValue();
dict->SetString("operation", operation);
@@ -183,10 +183,10 @@ base::Value* FileErrorCallback(const char* operation,
return dict;
}
-base::Value* FileInterruptedCallback(const char* operation,
- int os_error,
- content::DownloadInterruptReason reason,
- net::NetLog::LogLevel /* log_level */) {
+base::Value* FileInterruptedNetLogCallback(const char* operation,
+ int os_error,
+ DownloadInterruptReason reason,
+ net::NetLog::LogLevel log_level) {
DictionaryValue* dict = new DictionaryValue();
dict->SetString("operation", operation);
@@ -198,4 +198,4 @@ base::Value* FileInterruptedCallback(const char* operation,
}
-} // namespace download_net_logs
+} // namespace content
diff --git a/content/browser/download/download_net_log_parameters.h b/content/browser/download/download_net_log_parameters.h
index 1d94233..92432c1 100644
--- a/content/browser/download/download_net_log_parameters.h
+++ b/content/browser/download/download_net_log_parameters.h
@@ -14,7 +14,7 @@
class FilePath;
class GURL;
-namespace download_net_logs {
+namespace content {
enum DownloadType {
SRC_NEW_DOWNLOAD,
@@ -23,68 +23,68 @@ enum DownloadType {
};
// Returns NetLog parameters when a DownloadItem is activated.
-base::Value* ItemActivatedCallback(
- const content::DownloadItem* download_item,
+base::Value* ItemActivatedNetLogCallback(
+ const DownloadItem* download_item,
DownloadType download_type,
const std::string* file_name,
net::NetLog::LogLevel log_level);
// Returns NetLog parameters when a DownloadItem is checked for danger.
-base::Value* ItemCheckedCallback(
- content::DownloadDangerType danger_type,
- content::DownloadItem::SafetyState safety_state,
+base::Value* ItemCheckedNetLogCallback(
+ DownloadDangerType danger_type,
+ DownloadItem::SafetyState safety_state,
net::NetLog::LogLevel log_level);
// Returns NetLog parameters when a DownloadItem is renamed.
-base::Value* ItemRenamedCallback(const FilePath* old_filename,
- const FilePath* new_filename,
- net::NetLog::LogLevel log_level);
+base::Value* ItemRenamedNetLogCallback(const FilePath* old_filename,
+ const FilePath* new_filename,
+ net::NetLog::LogLevel log_level);
// Returns NetLog parameters when a DownloadItem is interrupted.
-base::Value* ItemInterruptedCallback(content::DownloadInterruptReason reason,
- int64 bytes_so_far,
- const std::string* hash_state,
- net::NetLog::LogLevel log_level);
+base::Value* ItemInterruptedNetLogCallback(DownloadInterruptReason reason,
+ int64 bytes_so_far,
+ const std::string* hash_state,
+ net::NetLog::LogLevel log_level);
// Returns NetLog parameters when a DownloadItem is completing.
-base::Value* ItemCompletingCallback(int64 bytes_so_far,
- const std::string* final_hash,
- net::NetLog::LogLevel log_level);
+base::Value* ItemCompletingNetLogCallback(int64 bytes_so_far,
+ const std::string* final_hash,
+ net::NetLog::LogLevel log_level);
// Returns NetLog parameters when a DownloadItem is finished.
-base::Value* ItemFinishedCallback(bool auto_opened,
- net::NetLog::LogLevel log_level);
+base::Value* ItemFinishedNetLogCallback(bool auto_opened,
+ net::NetLog::LogLevel log_level);
// Returns NetLog parameters when a DownloadItem is canceled.
-base::Value* ItemCanceledCallback(int64 bytes_so_far,
- const std::string* hash_state,
- net::NetLog::LogLevel log_level);
+base::Value* ItemCanceledNetLogCallback(int64 bytes_so_far,
+ const std::string* hash_state,
+ net::NetLog::LogLevel log_level);
// Returns NetLog parameters when a DownloadFile is opened.
-base::Value* FileOpenedCallback(const FilePath* file_name,
- int64 start_offset,
- net::NetLog::LogLevel log_level);
+base::Value* FileOpenedNetLogCallback(const FilePath* file_name,
+ int64 start_offset,
+ net::NetLog::LogLevel log_level);
// Returns NetLog parameters when a DownloadFile is opened.
-base::Value* FileStreamDrainedCallback(size_t stream_size,
- size_t num_buffers,
- net::NetLog::LogLevel log_level);
+base::Value* FileStreamDrainedNetLogCallback(size_t stream_size,
+ size_t num_buffers,
+ net::NetLog::LogLevel log_level);
// Returns NetLog parameters when a DownloadFile is renamed.
-base::Value* FileRenamedCallback(const FilePath* old_filename,
- const FilePath* new_filename,
- net::NetLog::LogLevel log_level);
+base::Value* FileRenamedNetLogCallback(const FilePath* old_filename,
+ const FilePath* new_filename,
+ net::NetLog::LogLevel log_level);
// Returns NetLog parameters when a File has an error.
-base::Value* FileErrorCallback(const char* operation,
- net::Error net_error,
- net::NetLog::LogLevel log_level);
-
-base::Value* FileInterruptedCallback(const char* operation,
- int os_error,
- content::DownloadInterruptReason reason,
+base::Value* FileErrorNetLogCallback(const char* operation,
+ net::Error net_error,
net::NetLog::LogLevel log_level);
-} // namespace download_net_logs
+base::Value* FileInterruptedNetLogCallback(const char* operation,
+ int os_error,
+ DownloadInterruptReason reason,
+ net::NetLog::LogLevel log_level);
+
+} // namespace content
#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_NET_LOG_PARAMETERS_H_
diff --git a/content/browser/download/download_request_handle.cc b/content/browser/download/download_request_handle.cc
index 43682e4..35b1125 100644
--- a/content/browser/download/download_request_handle.cc
+++ b/content/browser/download/download_request_handle.cc
@@ -11,10 +11,7 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
-using content::BrowserContext;
-using content::BrowserThread;
-using content::DownloadManager;
-using content::RenderViewHostImpl;
+namespace content {
DownloadRequestHandle::~DownloadRequestHandle() {
}
@@ -37,7 +34,7 @@ DownloadRequestHandle::DownloadRequestHandle(
DCHECK(handler_);
}
-content::WebContents* DownloadRequestHandle::GetWebContents() const {
+WebContents* DownloadRequestHandle::GetWebContents() const {
RenderViewHostImpl* render_view_host =
RenderViewHostImpl::FromID(child_id_, render_view_id_);
if (!render_view_host)
@@ -51,10 +48,10 @@ DownloadManager* DownloadRequestHandle::GetDownloadManager() const {
child_id_, render_view_id_);
if (rvh == NULL)
return NULL;
- content::RenderProcessHost* rph = rvh->GetProcess();
+ RenderProcessHost* rph = rvh->GetProcess();
if (rph == NULL)
return NULL;
- content::BrowserContext* context = rph->GetBrowserContext();
+ BrowserContext* context = rph->GetBrowserContext();
if (context == NULL)
return NULL;
return BrowserContext::GetDownloadManager(context);
@@ -88,3 +85,5 @@ std::string DownloadRequestHandle::DebugString() const {
render_view_id_,
request_id_);
}
+
+} // namespace content
diff --git a/content/browser/download/download_request_handle.h b/content/browser/download/download_request_handle.h
index f06985c..b8deac2 100644
--- a/content/browser/download/download_request_handle.h
+++ b/content/browser/download/download_request_handle.h
@@ -15,7 +15,6 @@
namespace content {
class DownloadManager;
class WebContents;
-}
// A handle used by the download system for operations on the URLRequest
// or objects conditional on it (e.g. WebContentsImpl).
@@ -28,8 +27,8 @@ class CONTENT_EXPORT DownloadRequestHandleInterface {
virtual ~DownloadRequestHandleInterface() {}
// These functions must be called on the UI thread.
- virtual content::WebContents* GetWebContents() const = 0;
- virtual content::DownloadManager* GetDownloadManager() const = 0;
+ virtual WebContents* GetWebContents() const = 0;
+ virtual DownloadManager* GetDownloadManager() const = 0;
// Pauses or resumes the matching URL request.
virtual void PauseRequest() const = 0;
@@ -64,8 +63,8 @@ class CONTENT_EXPORT DownloadRequestHandle
int request_id);
// Implement DownloadRequestHandleInterface interface.
- virtual content::WebContents* GetWebContents() const OVERRIDE;
- virtual content::DownloadManager* GetDownloadManager() const OVERRIDE;
+ virtual WebContents* GetWebContents() const OVERRIDE;
+ virtual DownloadManager* GetDownloadManager() const OVERRIDE;
virtual void PauseRequest() const OVERRIDE;
virtual void ResumeRequest() const OVERRIDE;
virtual void CancelRequest() const OVERRIDE;
@@ -84,4 +83,6 @@ class CONTENT_EXPORT DownloadRequestHandle
int request_id_;
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_
diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc
index 209617a..a579faf 100644
--- a/content/browser/download/download_resource_handler.cc
+++ b/content/browser/download/download_resource_handler.cc
@@ -30,13 +30,7 @@
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request_context.h"
-using content::BrowserThread;
-using content::DownloadId;
-using content::DownloadItem;
-using content::DownloadManager;
-using content::ResourceDispatcherHostImpl;
-using content::ResourceRequestInfoImpl;
-
+namespace content {
namespace {
static const int kDownloadByteStreamSize = 100 * 1024;
@@ -56,7 +50,7 @@ void CallStartedCBOnUIThread(
// DownloadResourceHandler members from the UI thread.
static void StartOnUIThread(
scoped_ptr<DownloadCreateInfo> info,
- scoped_ptr<content::ByteStreamReader> stream,
+ scoped_ptr<ByteStreamReader> stream,
const DownloadResourceHandler::OnStartedCallback& started_cb) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -81,7 +75,7 @@ static void StartOnUIThread(
DownloadResourceHandler::DownloadResourceHandler(
net::URLRequest* request,
const DownloadResourceHandler::OnStartedCallback& started_cb,
- scoped_ptr<content::DownloadSaveInfo> save_info)
+ scoped_ptr<DownloadSaveInfo> save_info)
: render_view_id_(0), // Actually initialized below.
content_length_(0),
request_(request),
@@ -96,7 +90,7 @@ DownloadResourceHandler::DownloadResourceHandler(
global_id_ = info->GetGlobalRequestID();
render_view_id_ = info->GetRouteID();
- download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT);
+ RecordDownloadCount(UNTHROTTLED_COUNT);
}
bool DownloadResourceHandler::OnUploadProgress(int request_id,
@@ -109,7 +103,7 @@ bool DownloadResourceHandler::OnUploadProgress(int request_id,
bool DownloadResourceHandler::OnRequestRedirected(
int request_id,
const GURL& url,
- content::ResourceResponse* response,
+ ResourceResponse* response,
bool* defer) {
return true;
}
@@ -117,7 +111,7 @@ bool DownloadResourceHandler::OnRequestRedirected(
// Send the download creation information to the download thread.
bool DownloadResourceHandler::OnResponseStarted(
int request_id,
- content::ResourceResponse* response,
+ ResourceResponse* response,
bool* defer) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// There can be only one (call)
@@ -147,7 +141,7 @@ bool DownloadResourceHandler::OnResponseStarted(
request_info->transition_type()));
// Create the ByteStream for sending data to the download sink.
- scoped_ptr<content::ByteStreamReader> stream_reader;
+ scoped_ptr<ByteStreamReader> stream_reader;
CreateByteStream(
base::MessageLoopProxy::current(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
@@ -165,7 +159,7 @@ bool DownloadResourceHandler::OnResponseStarted(
info->content_disposition = content_disposition_;
info->mime_type = response->head.mime_type;
info->remote_address = request_->GetSocketAddress().host();
- download_stats::RecordDownloadMimeType(info->mime_type);
+ RecordDownloadMimeType(info->mime_type);
info->request_handle =
DownloadRequestHandle(AsWeakPtr(), global_id_.child_id,
@@ -261,7 +255,7 @@ bool DownloadResourceHandler::OnReadCompleted(int request_id, int bytes_read,
double actual_bandwidth = (bytes_read)/seconds_since_last_read;
double potential_bandwidth = last_buffer_size_/seconds_since_last_read;
- download_stats::RecordBandwidth(actual_bandwidth, potential_bandwidth);
+ RecordBandwidth(actual_bandwidth, potential_bandwidth);
}
last_read_time_ = now;
@@ -315,9 +309,9 @@ bool DownloadResourceHandler::OnResponseCompleted(
error_code == net::ERR_INCOMPLETE_CHUNKED_ENCODING) {
error_code = net::OK;
}
- content::DownloadInterruptReason reason =
- content::ConvertNetErrorToInterruptReason(
- error_code, content::DOWNLOAD_INTERRUPT_FROM_NETWORK);
+ DownloadInterruptReason reason =
+ ConvertNetErrorToInterruptReason(
+ error_code, DOWNLOAD_INTERRUPT_FROM_NETWORK);
if (status.status() == net::URLRequestStatus::CANCELED &&
status.error() == net::ERR_ABORTED) {
@@ -329,30 +323,30 @@ bool DownloadResourceHandler::OnResponseCompleted(
// to a user action.
// TODO(ahendrickson) -- Find a better set of codes to use here, as
// CANCELED/ERR_ABORTED can occur for reasons other than user cancel.
- reason = content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED;
+ reason = DOWNLOAD_INTERRUPT_REASON_USER_CANCELED;
}
if (status.is_success()) {
if (response_code >= 400) {
switch(response_code) {
case 404: // File Not Found.
- reason = content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT;
+ reason = DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT;
break;
case 416: // Range Not Satisfiable.
- reason = content::DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE;
+ reason = DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE;
break;
case 412: // Precondition Failed.
- reason = content::DOWNLOAD_INTERRUPT_REASON_SERVER_PRECONDITION;
+ reason = DOWNLOAD_INTERRUPT_REASON_SERVER_PRECONDITION;
break;
default:
- reason = content::DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED;
+ reason = DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED;
break;
}
}
}
- download_stats::RecordAcceptsRanges(accept_ranges_, bytes_read_);
- download_stats::RecordNetworkBlockage(
+ RecordAcceptsRanges(accept_ranges_, bytes_read_);
+ RecordNetworkBlockage(
base::TimeTicks::Now() - download_start_time_, total_pause_time_);
CallStartedCB(NULL, error_code);
@@ -451,3 +445,5 @@ DownloadResourceHandler::~DownloadResourceHandler() {
UMA_HISTOGRAM_TIMES("SB2.DownloadDuration",
base::TimeTicks::Now() - download_start_time_);
}
+
+} // namespace content
diff --git a/content/browser/download/download_resource_handler.h b/content/browser/download/download_resource_handler.h
index 36f51ab..a093750 100644
--- a/content/browser/download/download_resource_handler.h
+++ b/content/browser/download/download_resource_handler.h
@@ -18,30 +18,29 @@
#include "content/public/browser/global_request_id.h"
#include "net/base/net_errors.h"
-class DownloadRequestHandle;
-struct DownloadCreateInfo;
-
-namespace content {
-class ByteStreamWriter;
-class ByteStreamReader;
-}
namespace net {
class URLRequest;
} // namespace net
+namespace content {
+class ByteStreamWriter;
+class ByteStreamReader;
+class DownloadRequestHandle;
+struct DownloadCreateInfo;
+
// Forwards data to the download thread.
class DownloadResourceHandler
- : public content::ResourceHandler,
+ : public ResourceHandler,
public base::SupportsWeakPtr<DownloadResourceHandler> {
public:
- typedef content::DownloadUrlParameters::OnStartedCallback OnStartedCallback;
+ typedef DownloadUrlParameters::OnStartedCallback OnStartedCallback;
// started_cb will be called exactly once on the UI thread.
DownloadResourceHandler(
net::URLRequest* request,
const OnStartedCallback& started_cb,
- scoped_ptr<content::DownloadSaveInfo> save_info);
+ scoped_ptr<DownloadSaveInfo> save_info);
virtual bool OnUploadProgress(int request_id,
uint64 position,
@@ -50,12 +49,12 @@ class DownloadResourceHandler
// Not needed, as this event handler ought to be the final resource.
virtual bool OnRequestRedirected(int request_id,
const GURL& url,
- content::ResourceResponse* response,
+ ResourceResponse* response,
bool* defer) OVERRIDE;
// Send the download creation information to the download thread.
virtual bool OnResponseStarted(int request_id,
- content::ResourceResponse* response,
+ ResourceResponse* response,
bool* defer) OVERRIDE;
// Pass-through implementation.
@@ -89,7 +88,7 @@ class DownloadResourceHandler
// Arrange for started_cb_ to be called on the UI thread with the
// below values, nulling out started_cb_. Should only be called
// on the IO thread.
- void CallStartedCB(content::DownloadItem* item, net::Error error);
+ void CallStartedCB(DownloadItem* item, net::Error error);
// If the content-length header is not present (or contains something other
// than numbers), the incoming content_length is -1 (unknown size).
@@ -98,7 +97,7 @@ class DownloadResourceHandler
void SetContentDisposition(const std::string& content_disposition);
- content::GlobalRequestID global_id_;
+ GlobalRequestID global_id_;
int render_view_id_;
std::string content_disposition_;
int64 content_length_;
@@ -106,11 +105,11 @@ class DownloadResourceHandler
// This is read only on the IO thread, but may only
// be called on the UI thread.
OnStartedCallback started_cb_;
- scoped_ptr<content::DownloadSaveInfo> save_info_;
+ scoped_ptr<DownloadSaveInfo> save_info_;
// Data flow
scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest.
- scoped_ptr<content::ByteStreamWriter> stream_writer_; // To rest of system.
+ scoped_ptr<ByteStreamWriter> stream_writer_; // To rest of system.
// The following are used to collect stats.
base::TimeTicks download_start_time_;
@@ -133,4 +132,6 @@ class DownloadResourceHandler
DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_
diff --git a/content/browser/download/download_stats.cc b/content/browser/download/download_stats.cc
index f1492dd..b454c27 100644
--- a/content/browser/download/download_stats.cc
+++ b/content/browser/download/download_stats.cc
@@ -9,7 +9,7 @@
#include "content/browser/download/download_resource_handler.h"
#include "content/public/browser/download_interrupt_reasons.h"
-namespace download_stats {
+namespace content {
// All possible error codes from the network module. Note that the error codes
// are all positive (since histograms expect positive sample values).
@@ -41,7 +41,7 @@ void RecordDownloadCompleted(const base::TimeTicks& start, int64 download_len) {
256);
}
-void RecordDownloadInterrupted(content::DownloadInterruptReason reason,
+void RecordDownloadInterrupted(DownloadInterruptReason reason,
int64 received,
int64 total) {
RecordDownloadCount(INTERRUPTED_COUNT);
@@ -346,4 +346,4 @@ void RecordSavePackageEvent(SavePackageEvent event) {
SAVE_PACKAGE_LAST_ENTRY);
}
-} // namespace download_stats
+} // namespace content
diff --git a/content/browser/download/download_stats.h b/content/browser/download/download_stats.h
index c2c4217..3e5feb4 100644
--- a/content/browser/download/download_stats.h
+++ b/content/browser/download/download_stats.h
@@ -19,7 +19,7 @@ class TimeDelta;
class TimeTicks;
}
-namespace download_stats {
+namespace content {
// We keep a count of how often various events occur in the
// histogram "Download.Counts".
@@ -99,7 +99,7 @@ void RecordDownloadSource(DownloadSource source);
void RecordDownloadCompleted(const base::TimeTicks& start, int64 download_len);
// Record INTERRUPTED_COUNT, |reason|, |received| and |total| bytes.
-void RecordDownloadInterrupted(content::DownloadInterruptReason reason,
+void RecordDownloadInterrupted(DownloadInterruptReason reason,
int64 received,
int64 total);
@@ -172,6 +172,6 @@ enum SavePackageEvent {
void RecordSavePackageEvent(SavePackageEvent event);
-} // namespace download_stats
+} // namespace content
#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_
diff --git a/content/browser/download/drag_download_file.cc b/content/browser/download/drag_download_file.cc
index 323a69a..2194e7b 100644
--- a/content/browser/download/drag_download_file.cc
+++ b/content/browser/download/drag_download_file.cc
@@ -16,18 +16,13 @@
#include "content/public/browser/download_url_parameters.h"
#include "net/base/file_stream.h"
-using content::BrowserContext;
-using content::BrowserThread;
-using content::DownloadItem;
-using content::DownloadManager;
-using content::DownloadUrlParameters;
-using content::WebContents;
+namespace content {
DragDownloadFile::DragDownloadFile(
const FilePath& file_name_or_path,
scoped_ptr<net::FileStream> file_stream,
const GURL& url,
- const content::Referrer& referrer,
+ const Referrer& referrer,
const std::string& referrer_encoding,
WebContents* web_contents)
: file_stream_(file_stream.Pass()),
@@ -133,13 +128,11 @@ void DragDownloadFile::InitiateDownload() {
download_manager_observer_added_ = true;
download_manager_->AddObserver(this);
- scoped_ptr<content::DownloadSaveInfo> save_info(
- new content::DownloadSaveInfo());
+ scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo());
save_info->file_path = file_path_;
save_info->file_stream = file_stream_.Pass(); // Nulls file_stream_
- download_stats::RecordDownloadSource(
- download_stats::INITIATED_BY_DRAG_N_DROP);
+ RecordDownloadSource(INITIATED_BY_DRAG_N_DROP);
scoped_ptr<DownloadUrlParameters> params(
DownloadUrlParameters::FromWebContents(
web_contents_, url_, save_info.Pass()));
@@ -199,7 +192,7 @@ void DragDownloadFile::ModelChanged(DownloadManager* manager) {
}
}
-void DragDownloadFile::OnDownloadUpdated(content::DownloadItem* download) {
+void DragDownloadFile::OnDownloadUpdated(DownloadItem* download) {
AssertCurrentlyOnUIThread();
if (download->IsCancelled()) {
RemoveObservers();
@@ -216,7 +209,7 @@ void DragDownloadFile::OnDownloadUpdated(content::DownloadItem* download) {
// OnDownloadDestroyed is only called if OnDownloadUpdated() does not detect
// completion or cancellation (in which cases it removes this observer).
// TODO(benjhayden): Try to change this to NOTREACHED()?
-void DragDownloadFile::OnDownloadDestroyed(content::DownloadItem* download) {
+void DragDownloadFile::OnDownloadDestroyed(DownloadItem* download) {
AssertCurrentlyOnUIThread();
RemoveObservers();
DownloadCompleted(false);
@@ -255,3 +248,5 @@ void DragDownloadFile::QuitNestedMessageLoop() {
}
}
#endif
+
+} // namespace content
diff --git a/content/browser/download/drag_download_file.h b/content/browser/download/drag_download_file.h
index 9132f57..90e00e7 100644
--- a/content/browser/download/drag_download_file.h
+++ b/content/browser/download/drag_download_file.h
@@ -17,19 +17,18 @@
#include "ui/base/dragdrop/download_file_interface.h"
#include "ui/base/ui_export.h"
-namespace content {
-class DownloadManager;
-class WebContents;
-}
-
namespace net {
class FileStream;
}
+namespace content {
+class DownloadManager;
+class WebContents;
+
class DragDownloadFile
: public ui::DownloadFileProvider,
- public content::DownloadManager::Observer,
- public content::DownloadItem::Observer {
+ public DownloadManager::Observer,
+ public DownloadItem::Observer {
public:
// On Windows, we need to download into a temporary file. Two threads are
// involved: background drag-and-drop thread and UI thread.
@@ -43,9 +42,9 @@ class DragDownloadFile
DragDownloadFile(const FilePath& file_name_or_path,
scoped_ptr<net::FileStream> file_stream,
const GURL& url,
- const content::Referrer& referrer,
+ const Referrer& referrer,
const std::string& referrer_encoding,
- content::WebContents* web_contents);
+ WebContents* web_contents);
// DownloadFileProvider methods.
// Called on drag-and-drop thread (Windows).
@@ -56,14 +55,14 @@ class DragDownloadFile
virtual IStream* GetStream() { return NULL; }
#endif
- // content::DownloadManager::Observer methods.
+ // DownloadManager::Observer methods.
// Called on UI thread.
- virtual void ModelChanged(content::DownloadManager* manager) OVERRIDE;
+ virtual void ModelChanged(DownloadManager* manager) OVERRIDE;
- // content::DownloadItem::Observer methods.
+ // DownloadItem::Observer methods.
// Called on UI thread.
- virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE;
- virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE;
+ virtual void OnDownloadUpdated(DownloadItem* download) OVERRIDE;
+ virtual void OnDownloadDestroyed(DownloadItem* download) OVERRIDE;
private:
// Called on drag-and-drop thread (Windows).
@@ -94,9 +93,9 @@ class DragDownloadFile
FilePath file_name_;
scoped_ptr<net::FileStream> file_stream_;
GURL url_;
- content::Referrer referrer_;
+ Referrer referrer_;
std::string referrer_encoding_;
- content::WebContents* web_contents_;
+ WebContents* web_contents_;
MessageLoop* drag_message_loop_;
FilePath temp_dir_path_;
@@ -112,11 +111,13 @@ class DragDownloadFile
#endif
// Access on UI thread.
- content::DownloadManager* download_manager_;
+ DownloadManager* download_manager_;
bool download_manager_observer_added_;
- content::DownloadItem* download_item_;
+ DownloadItem* download_item_;
DISALLOW_COPY_AND_ASSIGN(DragDownloadFile);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_H_
diff --git a/content/browser/download/drag_download_util.cc b/content/browser/download/drag_download_util.cc
index a62bbe4..f9ca5fe 100644
--- a/content/browser/download/drag_download_util.cc
+++ b/content/browser/download/drag_download_util.cc
@@ -19,10 +19,9 @@
#include "net/base/file_stream.h"
#include "net/base/net_errors.h"
-using content::BrowserThread;
using net::FileStream;
-namespace drag_download_util {
+namespace content {
bool ParseDownloadMetadata(const string16& metadata,
string16* mime_type,
@@ -117,4 +116,4 @@ void PromiseFileFinalizer::Cleanup() {
drag_file_downloader_ = NULL;
}
-} // namespace drag_download_util
+} // namespace content
diff --git a/content/browser/download/drag_download_util.h b/content/browser/download/drag_download_util.h
index 843bf7d..b84af94 100644
--- a/content/browser/download/drag_download_util.h
+++ b/content/browser/download/drag_download_util.h
@@ -17,7 +17,7 @@ namespace net {
class FileStream;
}
-namespace drag_download_util {
+namespace content {
// Parse the download metadata set in DataTransfer.setData. The metadata
// consists of a set of the following values separated by ":"
@@ -60,6 +60,6 @@ class PromiseFileFinalizer : public ui::DownloadFileObserver {
DISALLOW_COPY_AND_ASSIGN(PromiseFileFinalizer);
};
-} // namespace drag_download_util
+} // namespace content
#endif // CONTENT_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_UTIL_H_
diff --git a/content/browser/download/mhtml_generation_browsertest.cc b/content/browser/download/mhtml_generation_browsertest.cc
index 0eb2a0d..4fe0ef52 100644
--- a/content/browser/download/mhtml_generation_browsertest.cc
+++ b/content/browser/download/mhtml_generation_browsertest.cc
@@ -58,7 +58,7 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) {
path, base::Bind(&MHTMLGenerationTest::MHTMLGenerated, this));
// Block until the MHTML is generated.
- content::RunMessageLoop();
+ RunMessageLoop();
EXPECT_TRUE(mhtml_generated());
EXPECT_GT(file_size(), 0);
diff --git a/content/browser/download/mhtml_generation_manager.cc b/content/browser/download/mhtml_generation_manager.cc
index b1438c9..8559ced 100644
--- a/content/browser/download/mhtml_generation_manager.cc
+++ b/content/browser/download/mhtml_generation_manager.cc
@@ -14,9 +14,7 @@
#include "content/common/view_messages.h"
#include "content/public/browser/notification_types.h"
-using content::BrowserThread;
-using content::RenderViewHostImpl;
-using content::WebContents;
+namespace content {
MHTMLGenerationManager::Job::Job()
: browser_file(base::kInvalidPlatformFileValue),
@@ -137,3 +135,5 @@ void MHTMLGenerationManager::CloseFile(base::PlatformFile file) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
base::ClosePlatformFile(file);
}
+
+} // namespace content
diff --git a/content/browser/download/mhtml_generation_manager.h b/content/browser/download/mhtml_generation_manager.h
index f6ad716..54b8733 100644
--- a/content/browser/download/mhtml_generation_manager.h
+++ b/content/browser/download/mhtml_generation_manager.h
@@ -16,7 +16,6 @@ class FilePath;
namespace content {
class WebContents;
-}
class MHTMLGenerationManager {
public:
@@ -27,7 +26,7 @@ class MHTMLGenerationManager {
// Instructs the render view to generate a MHTML representation of the current
// page for |web_contents|.
- void GenerateMHTML(content::WebContents* web_contents,
+ void GenerateMHTML(WebContents* web_contents,
const FilePath& file,
const GenerateMHTMLCallback& callback);
@@ -88,4 +87,6 @@ class MHTMLGenerationManager {
DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_
diff --git a/content/browser/download/mock_download_file.cc b/content/browser/download/mock_download_file.cc
index 74e560b..9d883c7 100644
--- a/content/browser/download/mock_download_file.cc
+++ b/content/browser/download/mock_download_file.cc
@@ -8,10 +8,11 @@
using ::testing::_;
using ::testing::Return;
+namespace content {
namespace {
-void SuccessRun(const content::DownloadFile::InitializeCallback& callback) {
- callback.Run(content::DOWNLOAD_INTERRUPT_REASON_NONE);
+void SuccessRun(const DownloadFile::InitializeCallback& callback) {
+ callback.Run(DOWNLOAD_INTERRUPT_REASON_NONE);
}
} // namespace
@@ -25,3 +26,5 @@ MockDownloadFile::MockDownloadFile() {
MockDownloadFile::~MockDownloadFile() {
}
+
+} // namespace content
diff --git a/content/browser/download/mock_download_file.h b/content/browser/download/mock_download_file.h
index f5a1b6e..ae85b5e 100644
--- a/content/browser/download/mock_download_file.h
+++ b/content/browser/download/mock_download_file.h
@@ -16,19 +16,19 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace content {
struct DownloadCreateInfo;
-class MockDownloadFile : virtual public content::DownloadFile {
+class MockDownloadFile : virtual public DownloadFile {
public:
MockDownloadFile();
virtual ~MockDownloadFile();
// DownloadFile functions.
MOCK_METHOD1(Initialize, void(const InitializeCallback&));
- MOCK_METHOD2(AppendDataToFile, content::DownloadInterruptReason(
+ MOCK_METHOD2(AppendDataToFile, DownloadInterruptReason(
const char* data, size_t data_len));
- MOCK_METHOD1(Rename, content::DownloadInterruptReason(
- const FilePath& full_path));
+ MOCK_METHOD1(Rename, DownloadInterruptReason(const FilePath& full_path));
MOCK_METHOD3(Rename, void(const FilePath& full_path,
bool overwrite_existing_file,
const RenameCompletionCallback& callback));
@@ -44,9 +44,11 @@ class MockDownloadFile : virtual public content::DownloadFile {
MOCK_METHOD0(GetHashState, std::string());
MOCK_METHOD0(SendUpdate, void());
MOCK_CONST_METHOD0(Id, int());
- MOCK_METHOD0(GetDownloadManager, content::DownloadManager*());
- MOCK_CONST_METHOD0(GlobalId, const content::DownloadId&());
+ MOCK_METHOD0(GetDownloadManager, DownloadManager*());
+ MOCK_CONST_METHOD0(GlobalId, const DownloadId&());
MOCK_CONST_METHOD0(DebugString, std::string());
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_FILE_H_
diff --git a/content/browser/download/save_file.cc b/content/browser/download/save_file.cc
index 91fe2ac..854470b 100644
--- a/content/browser/download/save_file.cc
+++ b/content/browser/download/save_file.cc
@@ -8,7 +8,7 @@
#include "content/public/browser/browser_thread.h"
#include "net/base/file_stream.h"
-using content::BrowserThread;
+namespace content {
// TODO(asanka): SaveFile should use the target directory of the save package as
// the default download directory when initializing |file_|.
@@ -34,16 +34,16 @@ SaveFile::~SaveFile() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
}
-content::DownloadInterruptReason SaveFile::Initialize() {
+DownloadInterruptReason SaveFile::Initialize() {
return file_.Initialize(FilePath());
}
-content::DownloadInterruptReason SaveFile::AppendDataToFile(const char* data,
- size_t data_len) {
+DownloadInterruptReason SaveFile::AppendDataToFile(const char* data,
+ size_t data_len) {
return file_.AppendDataToFile(data, data_len);
}
-content::DownloadInterruptReason SaveFile::Rename(const FilePath& full_path) {
+DownloadInterruptReason SaveFile::Rename(const FilePath& full_path) {
return file_.Rename(full_path);
}
@@ -82,3 +82,5 @@ bool SaveFile::GetHash(std::string* hash) {
std::string SaveFile::DebugString() const {
return file_.DebugString();
}
+
+} // namespace content
diff --git a/content/browser/download/save_file.h b/content/browser/download/save_file.h
index fdcc33f..13b6f9d 100644
--- a/content/browser/download/save_file.h
+++ b/content/browser/download/save_file.h
@@ -11,6 +11,7 @@
#include "content/browser/download/base_file.h"
#include "content/browser/download/save_types.h"
+namespace content {
// SaveFile ----------------------------------------------------------------
// These objects live exclusively on the file thread and handle the writing
@@ -24,10 +25,9 @@ class SaveFile {
virtual ~SaveFile();
// BaseFile delegated functions.
- content::DownloadInterruptReason Initialize();
- content::DownloadInterruptReason AppendDataToFile(const char* data,
- size_t data_len);
- content::DownloadInterruptReason Rename(const FilePath& full_path);
+ DownloadInterruptReason Initialize();
+ DownloadInterruptReason AppendDataToFile(const char* data, size_t data_len);
+ DownloadInterruptReason Rename(const FilePath& full_path);
void Detach();
void Cancel();
void Finish();
@@ -54,4 +54,6 @@ class SaveFile {
DISALLOW_COPY_AND_ASSIGN(SaveFile);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_H_
diff --git a/content/browser/download/save_file_manager.cc b/content/browser/download/save_file_manager.cc
index 52b24cb..b23236f8 100644
--- a/content/browser/download/save_file_manager.cc
+++ b/content/browser/download/save_file_manager.cc
@@ -22,10 +22,7 @@
#include "net/base/io_buffer.h"
#include "net/base/net_util.h"
-using content::BrowserThread;
-using content::RenderViewHostImpl;
-using content::ResourceDispatcherHostImpl;
-using content::WebContentsImpl;
+namespace content {
SaveFileManager::SaveFileManager()
: next_id_(0) {
@@ -117,12 +114,12 @@ SavePackage* SaveFileManager::LookupPackage(int save_id) {
// Call from SavePackage for starting a saving job
void SaveFileManager::SaveURL(
const GURL& url,
- const content::Referrer& referrer,
+ const Referrer& referrer,
int render_process_host_id,
int render_view_id,
SaveFileCreateInfo::SaveFileSource save_source,
const FilePath& file_full_path,
- content::ResourceContext* context,
+ ResourceContext* context,
SavePackage* save_package) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -242,7 +239,7 @@ void SaveFileManager::UpdateSaveProgress(int save_id,
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
SaveFile* save_file = LookupSaveFile(save_id);
if (save_file) {
- content::DownloadInterruptReason reason =
+ DownloadInterruptReason reason =
save_file->AppendDataToFile(data->data(), data_len);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
@@ -250,7 +247,7 @@ void SaveFileManager::UpdateSaveProgress(int save_id,
this,
save_file->save_id(),
save_file->BytesSoFar(),
- reason == content::DOWNLOAD_INTERRUPT_REASON_NONE));
+ reason == DOWNLOAD_INTERRUPT_REASON_NONE));
}
}
@@ -356,10 +353,10 @@ void SaveFileManager::OnErrorFinished(const GURL& save_url, int contents_id) {
void SaveFileManager::OnSaveURL(
const GURL& url,
- const content::Referrer& referrer,
+ const Referrer& referrer,
int render_process_host_id,
int render_view_id,
- content::ResourceContext* context) {
+ ResourceContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
ResourceDispatcherHostImpl::Get()->BeginSaveFile(url,
referrer,
@@ -525,3 +522,5 @@ void SaveFileManager::RemoveSavedFileFromFileMap(
}
}
}
+
+} // namespace content
diff --git a/content/browser/download/save_file_manager.h b/content/browser/download/save_file_manager.h
index 3140ef4..73c7711 100644
--- a/content/browser/download/save_file_manager.h
+++ b/content/browser/download/save_file_manager.h
@@ -68,20 +68,19 @@
class FilePath;
class GURL;
-class SaveFile;
-class SavePackage;
-namespace content {
-struct Referrer;
-class ResourceContext;
-}
namespace net {
class IOBuffer;
}
-class SaveFileManager
- : public base::RefCountedThreadSafe<SaveFileManager> {
+namespace content {
+class ResourceContext;
+class SaveFile;
+class SavePackage;
+struct Referrer;
+
+class SaveFileManager : public base::RefCountedThreadSafe<SaveFileManager> {
public:
SaveFileManager();
@@ -96,12 +95,12 @@ class SaveFileManager
// Save the specified URL. Called on the UI thread and forwarded to the
// ResourceDispatcherHostImpl on the IO thread.
void SaveURL(const GURL& url,
- const content::Referrer& referrer,
+ const Referrer& referrer,
int render_process_host_id,
int render_view_id,
SaveFileCreateInfo::SaveFileSource save_source,
const FilePath& file_full_path,
- content::ResourceContext* context,
+ ResourceContext* context,
SavePackage* save_package);
// Notifications sent from the IO thread and run on the file thread:
@@ -206,10 +205,10 @@ class SaveFileManager
// Initiates a request for URL to be saved.
void OnSaveURL(const GURL& url,
- const content::Referrer& referrer,
+ const Referrer& referrer,
int render_process_host_id,
int render_view_id,
- content::ResourceContext* context);
+ ResourceContext* context);
// Handler for a notification sent to the IO thread for generating save id.
void OnRequireSaveJobFromOtherSource(SaveFileCreateInfo* info);
// Call ResourceDispatcherHostImpl's CancelRequest method to execute cancel
@@ -246,4 +245,6 @@ class SaveFileManager
DISALLOW_COPY_AND_ASSIGN(SaveFileManager);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H_
diff --git a/content/browser/download/save_file_resource_handler.cc b/content/browser/download/save_file_resource_handler.cc
index dd40d3b8..e2f2b89 100644
--- a/content/browser/download/save_file_resource_handler.cc
+++ b/content/browser/download/save_file_resource_handler.cc
@@ -13,7 +13,7 @@
#include "net/base/io_buffer.h"
#include "net/url_request/url_request_status.h"
-using content::BrowserThread;
+namespace content {
SaveFileResourceHandler::SaveFileResourceHandler(int render_process_host_id,
int render_view_id,
@@ -39,7 +39,7 @@ bool SaveFileResourceHandler::OnUploadProgress(int request_id,
bool SaveFileResourceHandler::OnRequestRedirected(
int request_id,
const GURL& url,
- content::ResourceResponse* response,
+ ResourceResponse* response,
bool* defer) {
final_url_ = url;
return true;
@@ -47,7 +47,7 @@ bool SaveFileResourceHandler::OnRequestRedirected(
bool SaveFileResourceHandler::OnResponseStarted(
int request_id,
- content::ResourceResponse* response,
+ ResourceResponse* response,
bool* defer) {
save_id_ = save_manager_->GetNextId();
// |save_manager_| consumes (deletes):
@@ -113,3 +113,5 @@ void SaveFileResourceHandler::set_content_length(
const std::string& content_length) {
base::StringToInt64(content_length, &content_length_);
}
+
+} // namespace content
diff --git a/content/browser/download/save_file_resource_handler.h b/content/browser/download/save_file_resource_handler.h
index b1d0ef1..e3cb359 100644
--- a/content/browser/download/save_file_resource_handler.h
+++ b/content/browser/download/save_file_resource_handler.h
@@ -10,10 +10,11 @@
#include "content/browser/renderer_host/resource_handler.h"
#include "googleurl/src/gurl.h"
+namespace content {
class SaveFileManager;
// Forwards data to the save thread.
-class SaveFileResourceHandler : public content::ResourceHandler {
+class SaveFileResourceHandler : public ResourceHandler {
public:
SaveFileResourceHandler(int render_process_host_id,
int render_view_id,
@@ -30,12 +31,12 @@ class SaveFileResourceHandler : public content::ResourceHandler {
// URL to match original request.
virtual bool OnRequestRedirected(int request_id,
const GURL& url,
- content::ResourceResponse* response,
+ ResourceResponse* response,
bool* defer) OVERRIDE;
// Sends the download creation information to the download thread.
virtual bool OnResponseStarted(int request_id,
- content::ResourceResponse* response,
+ ResourceResponse* response,
bool* defer) OVERRIDE;
// Pass-through implementation.
@@ -83,4 +84,6 @@ class SaveFileResourceHandler : public content::ResourceHandler {
DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_RENDERER_HOST_SAVE_FILE_RESOURCE_HANDLER_H_
diff --git a/content/browser/download/save_item.cc b/content/browser/download/save_item.cc
index 0d2001f..e225ffc 100644
--- a/content/browser/download/save_item.cc
+++ b/content/browser/download/save_item.cc
@@ -11,9 +11,11 @@
#include "content/browser/download/save_file_manager.h"
#include "content/browser/download/save_package.h"
+namespace content {
+
// Constructor for SaveItem when creating each saving job.
SaveItem::SaveItem(const GURL& url,
- const content::Referrer& referrer,
+ const Referrer& referrer,
SavePackage* package,
SaveFileCreateInfo::SaveFileSource save_source)
: save_id_(-1),
@@ -128,3 +130,5 @@ void SaveItem::SetTotalBytes(int64 total_bytes) {
DCHECK(total_bytes_ == 0);
total_bytes_ = total_bytes;
}
+
+} // namespace content
diff --git a/content/browser/download/save_item.h b/content/browser/download/save_item.h
index 8eacc5c..a78c28a 100644
--- a/content/browser/download/save_item.h
+++ b/content/browser/download/save_item.h
@@ -11,6 +11,7 @@
#include "content/public/common/referrer.h"
#include "googleurl/src/gurl.h"
+namespace content {
class SavePackage;
// One SaveItem per save file. This is the model class that stores all the
@@ -25,7 +26,7 @@ class SaveItem {
};
SaveItem(const GURL& url,
- const content::Referrer& referrer,
+ const Referrer& referrer,
SavePackage* package,
SaveFileCreateInfo::SaveFileSource save_source);
@@ -58,7 +59,7 @@ class SaveItem {
const FilePath& full_path() const { return full_path_; }
const FilePath& file_name() const { return file_name_; }
const GURL& url() const { return url_; }
- const content::Referrer& referrer() const { return referrer_; }
+ const Referrer& referrer() const { return referrer_; }
int64 total_bytes() const { return total_bytes_; }
int64 received_bytes() const { return received_bytes_; }
int32 save_id() const { return save_id_; }
@@ -84,7 +85,7 @@ class SaveItem {
// The URL for this save item.
GURL url_;
- content::Referrer referrer_;
+ Referrer referrer_;
// Total bytes expected.
int64 total_bytes_;
@@ -109,4 +110,6 @@ class SaveItem {
DISALLOW_COPY_AND_ASSIGN(SaveItem);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_SAVE_ITEM_H_
diff --git a/content/browser/download/save_package.cc b/content/browser/download/save_package.cc
index cc02d9c..6558b17 100644
--- a/content/browser/download/save_package.cc
+++ b/content/browser/download/save_package.cc
@@ -46,14 +46,9 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClient.h"
using base::Time;
-using content::BrowserContext;
-using content::BrowserThread;
-using content::DownloadItem;
-using content::NavigationEntry;
-using content::ResourceDispatcherHostImpl;
-using content::WebContents;
using WebKit::WebPageSerializerClient;
+namespace content {
namespace {
// A counter for uniquely identifying each save package.
@@ -120,10 +115,10 @@ const FilePath::CharType SavePackage::kDefaultHtmlExtension[] =
#endif
SavePackage::SavePackage(WebContents* web_contents,
- content::SavePageType save_type,
+ SavePageType save_type,
const FilePath& file_full_path,
const FilePath& directory_full_path)
- : content::WebContentsObserver(web_contents),
+ : WebContentsObserver(web_contents),
file_manager_(NULL),
download_manager_(NULL),
download_(NULL),
@@ -144,9 +139,9 @@ SavePackage::SavePackage(WebContents* web_contents,
wrote_to_completed_file_(false),
wrote_to_failed_file_(false) {
DCHECK(page_url_.is_valid());
- DCHECK((save_type_ == content::SAVE_PAGE_TYPE_AS_ONLY_HTML) ||
- (save_type_ == content::SAVE_PAGE_TYPE_AS_MHTML) ||
- (save_type_ == content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML));
+ DCHECK((save_type_ == SAVE_PAGE_TYPE_AS_ONLY_HTML) ||
+ (save_type_ == SAVE_PAGE_TYPE_AS_MHTML) ||
+ (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML));
DCHECK(!saved_main_file_path_.empty() &&
saved_main_file_path_.value().length() <= kMaxFilePathLength);
DCHECK(!saved_main_directory_path_.empty() &&
@@ -155,7 +150,7 @@ SavePackage::SavePackage(WebContents* web_contents,
}
SavePackage::SavePackage(WebContents* web_contents)
- : content::WebContentsObserver(web_contents),
+ : WebContentsObserver(web_contents),
file_manager_(NULL),
download_manager_(NULL),
download_(NULL),
@@ -166,7 +161,7 @@ SavePackage::SavePackage(WebContents* web_contents)
mhtml_finishing_(false),
user_canceled_(false),
disk_error_occurred_(false),
- save_type_(content::SAVE_PAGE_TYPE_UNKNOWN),
+ save_type_(SAVE_PAGE_TYPE_UNKNOWN),
all_save_items_count_(0),
wait_state_(INITIALIZE),
contents_id_(web_contents->GetRenderProcessHost()->GetID()),
@@ -183,7 +178,7 @@ SavePackage::SavePackage(WebContents* web_contents)
SavePackage::SavePackage(WebContents* web_contents,
const FilePath& file_full_path,
const FilePath& directory_full_path)
- : content::WebContentsObserver(web_contents),
+ : WebContentsObserver(web_contents),
file_manager_(NULL),
download_manager_(NULL),
download_(NULL),
@@ -194,7 +189,7 @@ SavePackage::SavePackage(WebContents* web_contents,
mhtml_finishing_(false),
user_canceled_(false),
disk_error_occurred_(false),
- save_type_(content::SAVE_PAGE_TYPE_UNKNOWN),
+ save_type_(SAVE_PAGE_TYPE_UNKNOWN),
all_save_items_count_(0),
wait_state_(INITIALIZE),
contents_id_(0),
@@ -249,8 +244,7 @@ void SavePackage::Cancel(bool user_action) {
disk_error_occurred_ = true;
Stop();
}
- download_stats::RecordSavePackageEvent(
- download_stats::SAVE_PACKAGE_CANCELLED);
+ RecordSavePackageEvent(SAVE_PACKAGE_CANCELLED);
}
// Init() can be called directly, or indirectly via GetSaveInfo(). In both
@@ -270,12 +264,11 @@ void SavePackage::InternalInit() {
web_contents()->GetBrowserContext()));
DCHECK(download_manager_);
- download_stats::RecordSavePackageEvent(download_stats::SAVE_PACKAGE_STARTED);
+ RecordSavePackageEvent(SAVE_PACKAGE_STARTED);
}
bool SavePackage::Init(
- const content::SavePackageDownloadCreatedCallback&
- download_created_callback) {
+ const SavePackageDownloadCreatedCallback& download_created_callback) {
// Set proper running state.
if (wait_state_ != INITIALIZE)
return false;
@@ -283,8 +276,7 @@ bool SavePackage::Init(
wait_state_ = START_PROCESS;
// Initialize the request context and resource dispatcher.
- content::BrowserContext* browser_context =
- web_contents()->GetBrowserContext();
+ BrowserContext* browser_context = web_contents()->GetBrowserContext();
if (!browser_context) {
NOTREACHED();
return false;
@@ -294,18 +286,18 @@ bool SavePackage::Init(
download_ = download_manager_->CreateSavePackageDownloadItem(
saved_main_file_path_,
page_url_,
- ((save_type_ == content::SAVE_PAGE_TYPE_AS_MHTML) ?
+ ((save_type_ == SAVE_PAGE_TYPE_AS_MHTML) ?
"multipart/related" : "text/html"),
this);
if (!download_created_callback.is_null())
download_created_callback.Run(download_);
// Check save type and process the save page job.
- if (save_type_ == content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML) {
+ if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML) {
// Get directory
DCHECK(!saved_main_directory_path_.empty());
GetAllSavableResourceLinksForCurrentPage();
- } else if (save_type_ == content::SAVE_PAGE_TYPE_AS_MHTML) {
+ } else if (save_type_ == SAVE_PAGE_TYPE_AS_MHTML) {
web_contents()->GenerateMHTML(saved_main_file_path_, base::Bind(
&SavePackage::OnMHTMLGenerated, this));
} else {
@@ -314,7 +306,7 @@ bool SavePackage::Init(
SaveFileCreateInfo::SAVE_FILE_FROM_FILE :
SaveFileCreateInfo::SAVE_FILE_FROM_NET;
SaveItem* save_item = new SaveItem(page_url_,
- content::Referrer(),
+ Referrer(),
this,
save_source);
// Add this item to waiting list.
@@ -551,7 +543,7 @@ void SavePackage::StartSave(const SaveFileCreateInfo* info) {
// When saving page as only-HTML, we only have a SaveItem whose url
// must be page_url_.
- DCHECK(save_type_ == content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML);
+ DCHECK(save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML);
DCHECK(!saved_main_directory_path_.empty());
// Now we get final name retrieved from GenerateFileName, we will use it
@@ -577,7 +569,7 @@ void SavePackage::StartSave(const SaveFileCreateInfo* info) {
}
// Check whether we begin to require serialized HTML data.
- if (save_type_ == content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML &&
+ if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML &&
wait_state_ == HTML_DATA) {
// Inform backend to serialize the all frames' DOM and send serialized
// HTML data back.
@@ -692,7 +684,7 @@ void SavePackage::CheckFinish() {
if (in_process_count() || finished_)
return;
- FilePath dir = (save_type_ == content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML &&
+ FilePath dir = (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML &&
saved_success_items_.size() > 1) ?
saved_main_directory_path_ : FilePath();
@@ -726,17 +718,15 @@ void SavePackage::Finish() {
finished_ = true;
// Record finish.
- download_stats::RecordSavePackageEvent(download_stats::SAVE_PACKAGE_FINISHED);
+ RecordSavePackageEvent(SAVE_PACKAGE_FINISHED);
// Record any errors that occurred.
if (wrote_to_completed_file_) {
- download_stats::RecordSavePackageEvent(
- download_stats::SAVE_PACKAGE_WRITE_TO_COMPLETED);
+ RecordSavePackageEvent(SAVE_PACKAGE_WRITE_TO_COMPLETED);
}
if (wrote_to_failed_file_) {
- download_stats::RecordSavePackageEvent(
- download_stats::SAVE_PACKAGE_WRITE_TO_FAILED);
+ RecordSavePackageEvent(SAVE_PACKAGE_WRITE_TO_FAILED);
}
// This vector contains the save ids of the save files which SaveFileManager
@@ -757,7 +747,7 @@ void SavePackage::Finish() {
// TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem
// with SavePackage flow.
if (download_->IsInProgress()) {
- if (save_type_ != content::SAVE_PAGE_TYPE_AS_MHTML) {
+ if (save_type_ != SAVE_PAGE_TYPE_AS_MHTML) {
download_->UpdateProgress(all_save_items_count_, CurrentSpeed(), "");
download_->OnAllDataSaved(DownloadItem::kEmptyFileHash);
}
@@ -835,8 +825,8 @@ void SavePackage::SaveFailed(const GURL& save_url) {
if (download_ && download_->IsInProgress())
download_->UpdateProgress(completed_count(), CurrentSpeed(), "");
- if ((save_type_ == content::SAVE_PAGE_TYPE_AS_ONLY_HTML) ||
- (save_type_ == content::SAVE_PAGE_TYPE_AS_MHTML) ||
+ if ((save_type_ == SAVE_PAGE_TYPE_AS_ONLY_HTML) ||
+ (save_type_ == SAVE_PAGE_TYPE_AS_MHTML) ||
(save_item->save_source() == SaveFileCreateInfo::SAVE_FILE_FROM_DOM)) {
// We got error when saving page. Treat it as disk error.
Cancel(true);
@@ -916,7 +906,7 @@ int64 SavePackage::CurrentSpeed() const {
// Continue processing the save page job after one SaveItem has been
// finished.
void SavePackage::DoSavingProcess() {
- if (save_type_ == content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML) {
+ if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML) {
// We guarantee that images and JavaScripts must be downloaded first.
// So when finishing all those sub-resources, we will know which
// sub-resource's link can be replaced with local file path, which
@@ -945,8 +935,8 @@ void SavePackage::DoSavingProcess() {
} else {
// Save as HTML only or MHTML.
DCHECK(wait_state_ == NET_FILES);
- DCHECK((save_type_ == content::SAVE_PAGE_TYPE_AS_ONLY_HTML) ||
- (save_type_ == content::SAVE_PAGE_TYPE_AS_MHTML));
+ DCHECK((save_type_ == SAVE_PAGE_TYPE_AS_ONLY_HTML) ||
+ (save_type_ == SAVE_PAGE_TYPE_AS_MHTML));
if (waiting_item_queue_.size()) {
DCHECK(all_save_items_count_ == waiting_item_queue_.size());
SaveNextFile(false);
@@ -1110,7 +1100,7 @@ void SavePackage::GetAllSavableResourceLinksForCurrentPage() {
// HTML data.
void SavePackage::OnReceivedSavableResourceLinksForCurrentPage(
const std::vector<GURL>& resources_list,
- const std::vector<content::Referrer>& referrers_list,
+ const std::vector<Referrer>& referrers_list,
const std::vector<GURL>& frames_list) {
if (wait_state_ != RESOURCES_LIST)
return;
@@ -1142,8 +1132,8 @@ void SavePackage::OnReceivedSavableResourceLinksForCurrentPage(
for (int i = 0; i < static_cast<int>(frames_list.size()); ++i) {
const GURL& u = frames_list[i];
DCHECK(u.is_valid());
- SaveItem* save_item = new SaveItem(u, content::Referrer(),
- this, SaveFileCreateInfo::SAVE_FILE_FROM_DOM);
+ SaveItem* save_item = new SaveItem(
+ u, Referrer(), this, SaveFileCreateInfo::SAVE_FILE_FROM_DOM);
waiting_item_queue_.push(save_item);
}
wait_state_ = NET_FILES;
@@ -1259,7 +1249,7 @@ const FilePath::CharType* SavePackage::ExtensionForMimeType(
}
WebContents* SavePackage::web_contents() const {
- return content::WebContentsObserver::web_contents();
+ return WebContentsObserver::web_contents();
}
void SavePackage::GetSaveInfo() {
@@ -1275,7 +1265,7 @@ void SavePackage::GetSaveInfo() {
}
std::string mime_type = web_contents()->GetContentsMimeType();
std::string accept_languages =
- content::GetContentClient()->browser()->GetAcceptLangs(
+ GetContentClient()->browser()->GetAcceptLangs(
web_contents()->GetBrowserContext());
BrowserThread::PostTask(
@@ -1354,9 +1344,8 @@ void SavePackage::ContinueGetSaveInfo(const FilePath& suggested_path,
void SavePackage::OnPathPicked(
const FilePath& final_name,
- content::SavePageType type,
- const content::SavePackageDownloadCreatedCallback&
- download_created_callback) {
+ SavePageType type,
+ const SavePackageDownloadCreatedCallback& download_created_callback) {
// Ensure the filename is safe.
saved_main_file_path_ = final_name;
// TODO(asanka): This call may block on IO and shouldn't be made
@@ -1366,7 +1355,7 @@ void SavePackage::OnPathPicked(
saved_main_directory_path_ = saved_main_file_path_.DirName();
save_type_ = type;
- if (save_type_ == content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML) {
+ if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML) {
// Make new directory for saving complete file.
saved_main_directory_path_ = saved_main_directory_path_.Append(
saved_main_file_path_.RemoveExtension().BaseName().value() +
@@ -1393,16 +1382,18 @@ void SavePackage::FinalizeDownloadEntry() {
DCHECK(download_);
DCHECK(download_manager_);
- content::NotificationService::current()->Notify(
- content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
+ NotificationService::current()->Notify(
+ NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
// We use the DownloadManager as the source as that's a
// central SavePackage related location that observers can
// get to if they want to wait for notifications for a
// particular BrowserContext. Alternatively, we could make
// it come from the WebContents, which would be more specific
// but less useful to (current) customers.
- content::Source<content::DownloadManager>(download_manager_),
- content::Details<content::DownloadItem>(download_));
+ Source<DownloadManager>(download_manager_),
+ Details<DownloadItem>(download_));
download_manager_->SavePageDownloadFinished(download_);
StopObservation();
}
+
+} // namespace content
diff --git a/content/browser/download/save_package.h b/content/browser/download/save_package.h
index aaa4377..ce415d6 100644
--- a/content/browser/download/save_package.h
+++ b/content/browser/download/save_package.h
@@ -24,18 +24,17 @@
#include "content/public/common/referrer.h"
#include "googleurl/src/gurl.h"
+class GURL;
+
+namespace content {
class DownloadItemImpl;
class DownloadManagerImpl;
-class GURL;
+class WebContents;
class SaveFileManager;
class SaveItem;
class SavePackage;
struct SaveFileCreateInfo;
-namespace content {
-class WebContents;
-}
-
// The SavePackage object manages the process of saving a page as only-html or
// complete-html or MHTML and providing the information for displaying saving
// status. Saving page as only-html means means that we save web page to a
@@ -52,8 +51,8 @@ class WebContents;
// saving job, and exist for the duration of one contents's life time.
class CONTENT_EXPORT SavePackage
: public base::RefCountedThreadSafe<SavePackage>,
- public content::WebContentsObserver,
- public content::DownloadItem::Observer,
+ public WebContentsObserver,
+ public DownloadItem::Observer,
public base::SupportsWeakPtr<SavePackage> {
public:
enum WaitState {
@@ -78,13 +77,13 @@ class CONTENT_EXPORT SavePackage
// Constructor for user initiated page saving. This constructor results in a
// SavePackage that will generate and sanitize a suggested name for the user
// in the "Save As" dialog box.
- explicit SavePackage(content::WebContents* web_contents);
+ explicit SavePackage(WebContents* web_contents);
// This contructor is used only for testing. We can bypass the file and
// directory name generation / sanitization by providing well known paths
// better suited for tests.
- SavePackage(content::WebContents* web_contents,
- content::SavePageType save_type,
+ SavePackage(WebContents* web_contents,
+ SavePageType save_type,
const FilePath& file_full_path,
const FilePath& directory_full_path);
@@ -93,7 +92,7 @@ class CONTENT_EXPORT SavePackage
// g_browser_process on a non-UI thread can cause crashes during shutdown.
// |cb| will be called when the DownloadItem is created, before data is
// written to disk.
- bool Init(const content::SavePackageDownloadCreatedCallback& cb);
+ bool Init(const SavePackageDownloadCreatedCallback& cb);
// Cancel all in progress request, might be called by user or internal error.
void Cancel(bool user_action);
@@ -113,21 +112,21 @@ class CONTENT_EXPORT SavePackage
bool canceled() const { return user_canceled_ || disk_error_occurred_; }
bool finished() const { return finished_; }
- content::SavePageType save_type() const { return save_type_; }
+ SavePageType save_type() const { return save_type_; }
int contents_id() const { return contents_id_; }
int id() const { return unique_id_; }
- content::WebContents* web_contents() const;
+ WebContents* web_contents() const;
void GetSaveInfo();
private:
friend class base::RefCountedThreadSafe<SavePackage>;
- // Callback for content::WebContents::GenerateMHTML().
+ // Callback for WebContents::GenerateMHTML().
void OnMHTMLGenerated(const FilePath& path, int64 size);
// For testing only.
- SavePackage(content::WebContents* web_contents,
+ SavePackage(WebContents* web_contents,
const FilePath& file_full_path,
const FilePath& directory_full_path);
@@ -141,11 +140,11 @@ class CONTENT_EXPORT SavePackage
void SaveNextFile(bool process_all_remainder_items);
void DoSavingProcess();
- // content::WebContentsObserver implementation.
+ // WebContentsObserver implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
- // content::DownloadItem::Observer implementation.
- virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE;
+ // DownloadItem::Observer implementation.
+ virtual void OnDownloadDestroyed(DownloadItem* download) OVERRIDE;
// Update the download history of this item upon completion.
void FinalizeDownloadEntry();
@@ -195,11 +194,11 @@ class CONTENT_EXPORT SavePackage
bool can_save_as_complete);
void OnPathPicked(
const FilePath& final_name,
- content::SavePageType type,
- const content::SavePackageDownloadCreatedCallback& cb);
+ SavePageType type,
+ const SavePackageDownloadCreatedCallback& cb);
void OnReceivedSavableResourceLinksForCurrentPage(
const std::vector<GURL>& resources_list,
- const std::vector<content::Referrer>& referrers_list,
+ const std::vector<Referrer>& referrers_list,
const std::vector<GURL>& frames_list);
void OnReceivedSerializedHtmlData(const GURL& frame_url,
@@ -291,7 +290,7 @@ class CONTENT_EXPORT SavePackage
bool disk_error_occurred_;
// Type about saving page as only-html or complete-html.
- content::SavePageType save_type_;
+ SavePageType save_type_;
// Number of all need to be saved resources.
size_t all_save_items_count_;
@@ -327,4 +326,6 @@ class CONTENT_EXPORT SavePackage
DISALLOW_COPY_AND_ASSIGN(SavePackage);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_
diff --git a/content/browser/download/save_package_unittest.cc b/content/browser/download/save_package_unittest.cc
index 74b73f0..fba1059 100644
--- a/content/browser/download/save_package_unittest.cc
+++ b/content/browser/download/save_package_unittest.cc
@@ -17,9 +17,7 @@
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
-using content::BrowserThread;
-using content::BrowserThreadImpl;
-using content::RenderViewHostImplTestHarness;
+namespace content {
#define FPL FILE_PATH_LITERAL
#if defined(OS_WIN)
@@ -428,3 +426,5 @@ TEST_F(SavePackageTest, TestGetUrlToBeSavedViewSource) {
EXPECT_EQ(actual_url, GetUrlToBeSaved());
EXPECT_EQ(view_source_url, contents()->GetURL());
}
+
+} // namespace content
diff --git a/content/browser/download/save_types.cc b/content/browser/download/save_types.cc
index 99cf1ae..59f9f35 100644
--- a/content/browser/download/save_types.cc
+++ b/content/browser/download/save_types.cc
@@ -4,6 +4,7 @@
#include "content/browser/download/save_types.h"
+namespace content {
SaveFileCreateInfo::SaveFileCreateInfo(const FilePath& path,
const GURL& url,
@@ -29,3 +30,5 @@ SaveFileCreateInfo::SaveFileCreateInfo()
}
SaveFileCreateInfo::~SaveFileCreateInfo() {}
+
+} // namespace content
diff --git a/content/browser/download/save_types.h b/content/browser/download/save_types.h
index 5684039..68a44c7 100644
--- a/content/browser/download/save_types.h
+++ b/content/browser/download/save_types.h
@@ -13,6 +13,7 @@
#include "base/file_path.h"
#include "googleurl/src/gurl.h"
+namespace content {
typedef std::vector<std::pair<int, FilePath> > FinalNameList;
typedef std::vector<int> SaveIDList;
@@ -64,4 +65,6 @@ struct SaveFileCreateInfo {
SaveFileSource save_source;
};
+} // namespace content
+
#endif // CONTENT_BROWSER_DOWNLOAD_SAVE_TYPES_H_