Commit 257202a6 authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Have one kMHTMLExtension constant instead of two

In jumbo builds many cc files compile in the same translation
unit and then they share the same anonymous namespace. Having
the same constant several times will then result in compilation
failures.

In preparation for jumbo in chrome/browser, this patch
deduplicates the kMHTMLExtension constant and puts it in the
utility class.

An alternative would be to use the literal string "mhtml" without
going through a constant at all.

Bug: 746957
Change-Id: I869f15c17bcf14a633a3e0711c7e469159e3083f
Reviewed-on: https://chromium-review.googlesource.com/897944Reviewed-by: default avatarCathy Li <chili@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#533764}
parent b17e66da
......@@ -26,8 +26,6 @@
namespace offline_pages {
namespace {
const base::FilePath::CharType kMHTMLExtension[] = FILE_PATH_LITERAL("mhtml");
void DeleteFileOnFileThread(const base::FilePath& file_path,
const base::Closure& callback) {
base::PostTaskWithTraitsAndReply(
......@@ -120,7 +118,8 @@ void OfflinePageMHTMLArchiver::GenerateMHTML(
GURL url(web_contents_->GetLastCommittedURL());
base::string16 title(web_contents_->GetTitle());
base::FilePath file_path(
archives_dir.Append(base::GenerateGUID()).AddExtension(kMHTMLExtension));
archives_dir.Append(base::GenerateGUID())
.AddExtension(OfflinePageUtils::kMHTMLExtension));
content::MHTMLGenerationParams params(file_path);
params.use_binary_encoding = true;
params.remove_popup_overlay = create_archive_params.remove_popup_overlay;
......
......@@ -141,6 +141,10 @@ void DoCalculateSizeBetween(
} // namespace
// static
const base::FilePath::CharType OfflinePageUtils::kMHTMLExtension[] =
FILE_PATH_LITERAL("mhtml");
// static
void OfflinePageUtils::SelectPagesForURL(
content::BrowserContext* browser_context,
......
......@@ -8,6 +8,7 @@
#include <stdint.h>
#include "base/callback.h"
#include "base/files/file_util.h"
#include "components/offline_pages/core/offline_page_model.h"
#include "components/offline_pages/core/offline_page_types.h"
#include "url/gurl.h"
......@@ -52,6 +53,8 @@ class OfflinePageUtils {
ALL = 0xFFFF
};
static const base::FilePath::CharType kMHTMLExtension[];
// Callback to inform the duplicate checking result.
using DuplicateCheckCallback = base::Callback<void(DuplicateCheckResult)>;
......
......@@ -13,6 +13,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "chrome/browser/offline_pages/offline_page_model_factory.h"
#include "chrome/browser/offline_pages/offline_page_utils.h"
#include "chrome/common/chrome_constants.h"
#include "components/offline_pages/core/offline_page_model.h"
#include "components/offline_pages/core/prefetch/prefetch_item.h"
......@@ -23,8 +24,6 @@ namespace offline_pages {
namespace {
const base::FilePath::CharType kMHTMLExtension[] = FILE_PATH_LITERAL("mhtml");
// Mirror of the OfflinePrefetchPageImportResult histogram enum so existing
// entries can never be removed and new ones must be appended with new values.
enum class PageImportResult {
......@@ -90,7 +89,8 @@ void PrefetchImporterImpl::ImportArchive(const PrefetchArchiveInfo& archive) {
base::FilePath archives_dir = offline_page_model->GetInternalArchiveDirectory(
archive.client_id.name_space);
base::FilePath dest_path =
archives_dir.Append(base::GenerateGUID()).AddExtension(kMHTMLExtension);
archives_dir.Append(base::GenerateGUID())
.AddExtension(OfflinePageUtils::kMHTMLExtension);
// For PrefetchArchiveInfo, |url| is the original URL while
// |final_archived_url| is the last committed URL which is set to empty when
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment