Platform cleanup in browser/ and porting of few files.

Review URL: http://codereview.chromium.org/14466

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7142 0039d316-1c4b-4281-b951-d872f2087c98
Esse commit está contido em:
phajdan.jr@chromium.org
2008-12-17 18:30:28 +00:00
commit 4325382137
11 arquivos alterados com 52 adições e 47 exclusões
+2
Ver Arquivo
@@ -67,8 +67,10 @@
#if defined(COMPILER_GCC)
#define ALLOW_UNUSED __attribute__((unused))
#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#else // Not GCC
#define ALLOW_UNUSED
#define WARN_UNUSED_RESULT
#endif
@@ -109,7 +109,7 @@ TEST_F(BookmarkHTMLWriterTest, Test) {
NULL);
// Verify we got back what we wrote.
ASSERT_EQ(6, parsed_bookmarks.size());
ASSERT_EQ(6U, parsed_bookmarks.size());
AssertBookmarkEntryEquals(parsed_bookmarks[0], false, url1, url1_title, t1,
L"Bookmark Bar", f1_title, std::wstring());
AssertBookmarkEntryEquals(parsed_bookmarks[1], false, url2, url2_title, t2,
+4 -4
Ver Arquivo
@@ -108,7 +108,11 @@ if env['PLATFORM'] in ('posix', 'win32'):
'session_startup_pref.cc',
'spellcheck_worditerator.cc',
'spellchecker.cc',
'ssl_error_info.cc',
'template_url.cc',
'template_url_model.cc',
'template_url_parser.cc',
'url_fetcher.cc',
'url_fetcher_protect.cc',
'user_metrics.cc',
'webdata/web_database.cc',
@@ -260,7 +264,6 @@ if env['PLATFORM'] == 'win32':
'shell_integration.cc',
'site_instance.cc',
'ssl_blocking_page.cc',
'ssl_error_info.cc',
'ssl_manager.cc',
'ssl_policy.cc',
'status_view.cc',
@@ -272,12 +275,9 @@ if env['PLATFORM'] == 'win32':
'tabs/tab_strip_model_order_controller.cc',
'task_manager.cc',
'task_manager_resource_providers.cc',
'template_url.cc',
'template_url_fetcher.cc',
'template_url_model.cc',
'template_url_prepopulate_data.cc',
'toolbar_model.cc',
'url_fetcher.cc',
'url_fixer_upper.cc',
'user_data_manager.cc',
'view_source_contents.cc',
+1 -1
Ver Arquivo
@@ -61,7 +61,7 @@ class CertStore : public NotificationObserver {
static CertStore* instance_;
typedef std::multimap<int, int> IDMap;
typedef std::map<int, scoped_refptr<net::X509Certificate>> CertMap;
typedef std::map<int, scoped_refptr<net::X509Certificate> > CertMap;
typedef std::map<net::X509Certificate*, int, net::X509Certificate::LessThan>
ReverseCertMap;
+1 -1
Ver Arquivo
@@ -24,7 +24,7 @@ TEST(GoogleURLTrackerTest, CheckAndConvertURL) {
{ "http://google/", false, "", },
};
for (size_t i = 0; i < arraysize(data); ++i) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
GURL base_url;
const bool can_convert = GoogleURLTracker::CheckAndConvertToGoogleBaseURL(
GURL(data[i].source_url), &base_url);
+14 -14
Ver Arquivo
@@ -57,7 +57,7 @@ class HistoryBackendTest : public testing::Test {
scoped_refptr<HistoryBackend> backend_; // Will be NULL on init failure.
scoped_ptr<InMemoryHistoryBackend> mem_backend_;
void AddRedirectChain(const wchar_t* sequence[], int page_id) {
void AddRedirectChain(const char* sequence[], int page_id) {
HistoryService::RedirectList redirects;
for (int i = 0; sequence[i] != NULL; ++i)
redirects.push_back(GURL(sequence[i]));
@@ -78,7 +78,7 @@ class HistoryBackendTest : public testing::Test {
bool loaded_;
private:
friend HistoryBackendTestDelegate;
friend class HistoryBackendTestDelegate;
// testing::Test
virtual void SetUp() {
@@ -104,7 +104,7 @@ class HistoryBackendTest : public testing::Test {
HistoryDetails* details) {
// Send the notifications directly to the in-memory database.
Details<HistoryDetails> det(details);
mem_backend_->Observe(type, Source<HistoryTest>(NULL), det);
mem_backend_->Observe(type, Source<HistoryBackendTest>(NULL), det);
// The backend passes ownership of the details pointer to us.
delete details;
@@ -178,12 +178,12 @@ TEST_F(HistoryBackendTest, DeleteAll) {
// Get the two visits for the URLs we just added.
VisitVector visits;
backend_->db_->GetVisitsForURL(row1_id, &visits);
ASSERT_EQ(1, visits.size());
ASSERT_EQ(1U, visits.size());
VisitID visit1_id = visits[0].visit_id;
visits.clear();
backend_->db_->GetVisitsForURL(row2_id, &visits);
ASSERT_EQ(1, visits.size());
ASSERT_EQ(1U, visits.size());
VisitID visit2_id = visits[0].visit_id;
// The in-memory backend should have been set and it should have gotten the
@@ -234,7 +234,7 @@ TEST_F(HistoryBackendTest, DeleteAll) {
// All visits should be deleted for both URLs.
VisitVector all_visits;
backend_->db_->GetAllVisitsInRange(Time(), Time(), 0, &all_visits);
ASSERT_EQ(0, all_visits.size());
ASSERT_EQ(0U, all_visits.size());
// All thumbnails should be deleted.
std::vector<unsigned char> out_data;
@@ -264,7 +264,7 @@ TEST_F(HistoryBackendTest, DeleteAll) {
backend_->text_database_->GetTextMatches(L"Body", QueryOptions(),
&text_matches,
&first_time_searched);
EXPECT_EQ(0, text_matches.size());
EXPECT_EQ(0U, text_matches.size());
}
TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) {
@@ -315,7 +315,7 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) {
EXPECT_EQ(row2_id, backend_->db_->GetRowForURL(row2.url(), NULL));
VisitVector visits;
backend_->db_->GetVisitsForURL(row2_id, &visits);
EXPECT_EQ(0, visits.size());
EXPECT_EQ(0U, visits.size());
// The favicon should still be valid.
EXPECT_EQ(favicon2,
backend_->thumbnail_db_->GetFavIconIDForFavIconURL(favicon_url2));
@@ -348,7 +348,7 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) {
// There should still be visits.
visits.clear();
backend_->db_->GetVisitsForURL(row1_id, &visits);
EXPECT_EQ(1, visits.size());
EXPECT_EQ(1U, visits.size());
// The favicon should still be valid.
EXPECT_EQ(favicon1,
@@ -358,9 +358,9 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) {
TEST_F(HistoryBackendTest, GetPageThumbnailAfterRedirects) {
ASSERT_TRUE(backend_.get());
const wchar_t* base_url = L"http://mail";
const wchar_t* thumbnail_url = L"http://mail.google.com";
const wchar_t* first_chain[] = {
const char* base_url = "http://mail";
const char* thumbnail_url = "http://mail.google.com";
const char* first_chain[] = {
base_url,
thumbnail_url,
NULL
@@ -376,9 +376,9 @@ TEST_F(HistoryBackendTest, GetPageThumbnailAfterRedirects) {
// Write a second URL chain so that if you were to simply check what
// "http://mail" redirects to, you wouldn't see the URL that has
// contains the thumbnail.
const wchar_t* second_chain[] = {
const char* second_chain[] = {
base_url,
L"http://mail.google.com/somewhere/else",
"http://mail.google.com/somewhere/else",
NULL
};
AddRedirectChain(second_chain, 1);
+1 -1
Ver Arquivo
@@ -113,7 +113,7 @@ TEST(MetricsLogTest, CreateHash) {
{"NewTab", "0x290eb683f96572f1"},
};
for (int i = 0; i < arraysize(cases); i++) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) {
std::string hash_string = MetricsLog::CreateHash(cases[i].input);
// Convert to hex string
+1 -2
Ver Arquivo
@@ -7,7 +7,6 @@
#include "base/string_util.h"
#include "chrome/browser/cert_store.h"
#include "chrome/common/l10n_util.h"
#include "chrome/common/resource_bundle.h"
#include "chrome/common/time_format.h"
#include "net/base/cert_status_flags.h"
#include "net/base/net_errors.h"
@@ -235,7 +234,7 @@ int SSLErrorInfo::GetErrorsForCertStatus(int cert_id,
scoped_refptr<net::X509Certificate> cert = NULL;
int count = 0;
for (int i = 0; i < arraysize(kErrorFlags); ++i) {
for (size_t i = 0; i < arraysize(kErrorFlags); ++i) {
if (cert_status & kErrorFlags[i]) {
count++;
if (!cert.get()) {
+4 -4
Ver Arquivo
@@ -4,19 +4,19 @@
#include "chrome/browser/url_fetcher.h"
#include "base/compiler_specific.h"
#include "base/string_util.h"
#include "base/thread.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/net/dns_master.h"
#include "googleurl/src/gurl.h"
#include "net/base/load_flags.h"
URLFetcher::URLFetcher(const GURL& url,
RequestType request_type,
Delegate* d)
#pragma warning(suppress: 4355) // Okay to pass "this" here.
: core_(new Core(this, url, request_type, d)) {
: ALLOW_THIS_IN_INITIALIZER_LIST(
core_(new Core(this, url, request_type, d))) {
}
URLFetcher::~URLFetcher() {
@@ -34,8 +34,8 @@ URLFetcher::Core::Core(URLFetcher* fetcher,
delegate_loop_(MessageLoop::current()),
io_loop_(ChromeThread::GetMessageLoop(ChromeThread::IO)),
request_(NULL),
response_code_(-1),
load_flags_(net::LOAD_NORMAL),
response_code_(-1),
protect_entry_(URLFetcherProtectManager::GetInstance()->Register(
original_url_.host())),
num_retries_(0) {
+17 -18
Ver Arquivo
@@ -3,9 +3,10 @@
// found in the LICENSE file.
#include <stdlib.h>
#include <windows.h>
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/string_util.h"
@@ -95,7 +96,7 @@ TEST(URLFixerUpperTest, SegmentURL) {
std::wstring result;
url_parse::Parsed parts;
for (int i = 0; i < arraysize(segment_cases); ++i) {
for (size_t i = 0; i < arraysize(segment_cases); ++i) {
segment_case value = segment_cases[i];
result = URLFixerUpper::SegmentURL(value.input, &parts);
EXPECT_EQ(value.result, result);
@@ -118,13 +119,12 @@ TEST(URLFixerUpperTest, SegmentURL) {
static bool MakeTempFile(const std::wstring& dir,
const std::wstring& file_name,
std::wstring* full_path) {
*full_path = dir + L"\\" + file_name;
HANDLE hfile = CreateFile(full_path->c_str(), GENERIC_READ | GENERIC_WRITE,
0, NULL, CREATE_ALWAYS, 0, NULL);
if (hfile == NULL || hfile == INVALID_HANDLE_VALUE)
FilePath dir_path = FilePath::FromWStringHack(dir);
FilePath file_name_path = FilePath::FromWStringHack(file_name);
FilePath path = dir_path.Append(file_name_path.value());
if (!file_util::CreateTemporaryFileName(&path))
return false;
CloseHandle(hfile);
*full_path = path.ToWStringHack();
return true;
}
@@ -139,7 +139,7 @@ static bool IsMatchingFileURL(const std::wstring& url,
return false; // contains backslashes
std::wstring derived_path;
net::FileURLToFilePath(GURL(url), &derived_path);
net::FileURLToFilePath(GURL(WideToUTF8(url)), &derived_path);
return (derived_path.length() == full_file_path.length()) &&
std::equal(derived_path.begin(), derived_path.end(),
full_file_path.begin(), CaseInsensitiveCompare<wchar_t>());
@@ -178,7 +178,7 @@ struct fixup_case {
TEST(URLFixerUpperTest, FixupURL) {
std::wstring output;
for (int i = 0; i < arraysize(fixup_cases); ++i) {
for (size_t i = 0; i < arraysize(fixup_cases); ++i) {
fixup_case value = fixup_cases[i];
output = URLFixerUpper::FixupURL(value.input, value.desired_tld);
EXPECT_EQ(value.output, output);
@@ -204,7 +204,7 @@ TEST(URLFixerUpperTest, FixupURL) {
{L"google:123", L"com", L"http://www.google.com:123/"},
{L"http://google:123", L"com", L"http://www.google.com:123/"},
};
for (int i = 0; i < arraysize(tld_cases); ++i) {
for (size_t i = 0; i < arraysize(tld_cases); ++i) {
fixup_case value = tld_cases[i];
output = URLFixerUpper::FixupURL(value.input, value.desired_tld);
EXPECT_EQ(value.output, output);
@@ -260,13 +260,13 @@ TEST(URLFixerUpperTest, FixupFile) {
// {L"file://server/folder/file", L"", L"file://server/folder/file"},
// {L"file:/\\/server\\folder/file", L"", L"file://server/folder/file"},
};
for (int i = 0; i < arraysize(file_cases); i++) {
for (size_t i = 0; i < arraysize(file_cases); i++) {
fixedup = URLFixerUpper::FixupURL(file_cases[i].input,
file_cases[i].desired_tld);
EXPECT_EQ(file_cases[i].output, fixedup);
}
EXPECT_TRUE(DeleteFile(original.c_str()));
EXPECT_TRUE(file_util::Delete(original, false));
}
TEST(URLFixerUpperTest, FixupRelativeFile) {
@@ -277,7 +277,7 @@ TEST(URLFixerUpperTest, FixupRelativeFile) {
// make sure we pass through good URLs
std::wstring fixedup;
for (int i = 0; i < arraysize(fixup_cases); ++i) {
for (size_t i = 0; i < arraysize(fixup_cases); ++i) {
fixup_case value = fixup_cases[i];
fixedup = URLFixerUpper::FixupRelativeFile(dir, value.input);
EXPECT_EQ(value.output, fixedup);
@@ -287,7 +287,7 @@ TEST(URLFixerUpperTest, FixupRelativeFile) {
// are no backslashes
fixedup = URLFixerUpper::FixupRelativeFile(dir, file_part);
EXPECT_PRED2(IsMatchingFileURL, fixedup, full_path);
EXPECT_TRUE(DeleteFile(full_path.c_str()));
EXPECT_TRUE(file_util::Delete(full_path, false));
// create a filename we know doesn't exist and make sure it doesn't get
// fixed up to a file URL
@@ -301,7 +301,7 @@ TEST(URLFixerUpperTest, FixupRelativeFile) {
std::wstring sub_dir(L"url fixer-upper dir");
std::wstring sub_file(L"url fixer-upper existing file.txt");
std::wstring new_dir = dir + L"\\" + sub_dir;
CreateDirectory(new_dir.c_str(), NULL);
ASSERT_TRUE(file_util::CreateDirectory(new_dir));
ASSERT_TRUE(MakeTempFile(new_dir, sub_file, &full_path));
// test file in the subdir
@@ -322,7 +322,6 @@ TEST(URLFixerUpperTest, FixupRelativeFile) {
EXPECT_PRED2(IsMatchingFileURL, fixedup, full_path);
// done with the subdir
EXPECT_TRUE(DeleteFile(full_path.c_str()));
EXPECT_TRUE(RemoveDirectory(new_dir.c_str()));
EXPECT_TRUE(file_util::Delete(new_dir, true));
}
+6 -1
Ver Arquivo
@@ -5,13 +5,18 @@
#ifndef CHROME_COMMON_GFX_FAVICON_SIZE_H__
#define CHROME_COMMON_GFX_FAVICON_SIZE_H__
#include "base/compiler_specific.h"
// Size (along each axis) of the favicon.
const int kFavIconSize = 16;
// If the width or height is bigger than the favicon size, a new width/height
// is calculated and returned in width/height that maintains the aspect
// ratio of the supplied values.
static void calc_favicon_target_size(int* width, int* height) {
static void calc_favicon_target_size(int* width, int* height) ALLOW_UNUSED;
// static
void calc_favicon_target_size(int* width, int* height) {
if (*width > kFavIconSize || *height > kFavIconSize) {
// Too big, resize it maintaining the aspect ratio.
float aspect_ratio = static_cast<float>(*width) /