diff options
-rw-r--r-- | base/base.xcodeproj/project.pbxproj | 14 | ||||
-rw-r--r-- | base/build/base.vcproj | 14 | ||||
-rw-r--r-- | base/compiler_specific.h | 80 | ||||
-rw-r--r-- | base/message_loop.cc | 3 | ||||
-rw-r--r-- | build/SConscript.main | 1 | ||||
-rw-r--r-- | build/internal/essential.vsprops | 2 | ||||
-rw-r--r-- | net/base/base64.cc | 3 | ||||
-rw-r--r-- | net/base/net_util_unittest.cc | 20 | ||||
-rw-r--r-- | net/http/http_cache.cc | 12 |
9 files changed, 116 insertions, 33 deletions
diff --git a/base/base.xcodeproj/project.pbxproj b/base/base.xcodeproj/project.pbxproj index d635f7c..684fb14 100644 --- a/base/base.xcodeproj/project.pbxproj +++ b/base/base.xcodeproj/project.pbxproj @@ -327,7 +327,6 @@ 7B8505A40E5B3FBE00730B43 /* size.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = size.cc; sourceTree = "<group>"; }; 7B8505A50E5B3FBE00730B43 /* skia_utils.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = skia_utils.cc; sourceTree = "<group>"; }; 7B8505A60E5B3FBE00730B43 /* skia_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = skia_utils.h; sourceTree = "<group>"; }; - 7B8505A70E5B3FBE00730B43 /* uniscribe_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = uniscribe_unittest.cc; sourceTree = "<group>"; }; 7B8505A80E5B3FBE00730B43 /* vector_canvas_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = vector_canvas_unittest.cc; sourceTree = "<group>"; }; 7BAF4F0A0E50A2FD00CA8A07 /* notimplemented.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = notimplemented.h; sourceTree = "<group>"; }; 7BAF4F7B0E50A3BD00CA8A07 /* logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = logging.h; sourceTree = "<group>"; }; @@ -336,6 +335,7 @@ 7BAF50750E50B8F100CA8A07 /* file_version_info_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_version_info_unittest.cc; sourceTree = "<group>"; }; 7BAF50A90E50BACB00CA8A07 /* string_util_posix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = string_util_posix.h; sourceTree = "<group>"; }; 7BAF50B10E50BAE700CA8A07 /* string_util_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = string_util_unittest.cc; sourceTree = "<group>"; }; + 7BAFFC8A0E5E0CC000797CC4 /* compiler_specific.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = compiler_specific.h; sourceTree = "<group>"; }; 7BD9E84E0DA447F800FC7A01 /* singleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = singleton.h; sourceTree = "<group>"; }; 7BEB81100D9AD288009BA8DD /* prcpucfg_mac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = prcpucfg_mac.h; path = third_party/nspr/prcpucfg_mac.h; sourceTree = "<group>"; }; 7BEB81490D9B0F33009BA8DD /* time_posix.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = time_posix.cc; sourceTree = "<group>"; }; @@ -696,6 +696,7 @@ E4A133490E37A41D00110AA2 /* command_line.cc */, E4A1334A0E37A41D00110AA2 /* command_line.h */, E45A2B5A0E479A1900DB1196 /* command_line_unittest.cc */, + 7BAFFC8A0E5E0CC000797CC4 /* compiler_specific.h */, 825402EB0D92D1940006B936 /* condition_variable.h */, 824653670DC12CEC007C2BAA /* condition_variable_posix.cc */, 825402F40D92D1AC0006B936 /* debug_on_start.cc */, @@ -906,7 +907,6 @@ 825403D70D92D31D0006B936 /* size.h */, 7B8505A50E5B3FBE00730B43 /* skia_utils.cc */, 7B8505A60E5B3FBE00730B43 /* skia_utils.h */, - 7B8505A70E5B3FBE00730B43 /* uniscribe_unittest.cc */, 825403DC0D92D31D0006B936 /* vector_canvas.cc */, 825403DD0D92D31D0006B936 /* vector_canvas.h */, 7B8505A80E5B3FBE00730B43 /* vector_canvas_unittest.cc */, @@ -1168,6 +1168,7 @@ 829E36460DC0F6AC00819EBF /* string_util.cc in Sources */, 820EB4FA0E3A6178009668FC /* string_util_icu.cc in Sources */, 7B4C5F4A0E4B6BF900679E8F /* sys_string_conversions_mac.cc in Sources */, + 93E703240E5D64F00046259B /* thread.cc in Sources */, 829E36730DC0FBAD00819EBF /* thread_local_storage_posix.cc in Sources */, 824654910DC25A8C007C2BAA /* time.cc in Sources */, 82D094550E5B892600FEC05C /* time_format.cc in Sources */, @@ -1178,7 +1179,6 @@ ABF4B9C30DC2BD6C00A6E319 /* values.cc in Sources */, 9301C03B0E54C839001EF103 /* waitable_event_generic.cc in Sources */, 824655DD0DC659B8007C2BAA /* word_iterator.cc in Sources */, - 93E703240E5D64F00046259B /* thread.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1405,12 +1405,12 @@ ); HEADER_SEARCH_PATHS = ( .., + ../skia/include, + ../skia/include/corecg, ../testing/gtest/include, ../testing/gtest/include/gtest, ../third_party/icu38/public/common, ../third_party/icu38/public/i18n, - ../skia/include, - ../skia/include/corecg, ); PRODUCT_NAME = base_unittests; }; @@ -1426,12 +1426,12 @@ ); HEADER_SEARCH_PATHS = ( .., + ../skia/include, + ../skia/include/corecg, ../testing/gtest/include, ../testing/gtest/include/gtest, ../third_party/icu38/public/common, ../third_party/icu38/public/i18n, - ../skia/include, - ../skia/include/corecg, ); PRODUCT_NAME = base_unittests; }; diff --git a/base/build/base.vcproj b/base/build/base.vcproj index b78f41c..7864bd0 100644 --- a/base/build/base.vcproj +++ b/base/build/base.vcproj @@ -234,6 +234,10 @@ > </File> <File + RelativePath="..\compiler_specific.h" + > + </File> + <File RelativePath="..\condition_variable.h" > </File> @@ -482,11 +486,11 @@ > </File> <File - RelativePath="..\platform_thread_win.cc" + RelativePath="..\platform_thread.h" > </File> <File - RelativePath="..\platform_thread.h" + RelativePath="..\platform_thread_win.cc" > </File> <File @@ -710,15 +714,15 @@ > </File> <File - RelativePath="..\time_win.cc" + RelativePath="..\time_format.cc" > </File> <File - RelativePath="..\time_format.cc" + RelativePath="..\time_format.h" > </File> <File - RelativePath="..\time_format.h" + RelativePath="..\time_win.cc" > </File> <File diff --git a/base/compiler_specific.h b/base/compiler_specific.h new file mode 100644 index 0000000..af00654 --- /dev/null +++ b/base/compiler_specific.h @@ -0,0 +1,80 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef BASE_COMPILER_SPECIFIC_H_ +#define BASE_COMPILER_SPECIFIC_H_ + +#include "build/build_config.h" + +#if defined(COMPILER_MSVC) + +// Macros for suppressing and disabling warnings on MSVC. +// +// Warning numbers are enumerated at: +// http://msdn.microsoft.com/en-us/library/8x5x43k7(VS.80).aspx +// +// The warning pragma: +// http://msdn.microsoft.com/en-us/library/2c8f766e(VS.80).aspx +// +// Using __pragma instead of #pragma inside macros: +// http://msdn.microsoft.com/en-us/library/d9x1s805.aspx + +// MSVC_SUPPRESS_WARNING disables warning |n| for the remainder of the line and +// for the next line of the source file. +#define MSVC_SUPPRESS_WARNING(n) __pragma(warning(suppress:n)) + +// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled. +// The warning remains disabled until popped by MSVC_POP_WARNING. +#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \ + __pragma(warning(disable:n)) +#define MSVC_POP_WARNING() __pragma(warning(pop)) + +// Allows |this| to be passed as an argument in constructor initializer lists. +// This uses push/pop instead of the seemingly simpler suppress feature to avoid +// having the warning be disabled for more than just |code|. +// +// Example usage: +// Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} +// +// Compiler warning C4355: 'this': used in base member initializer list: +// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx +#define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ + code \ + MSVC_POP_WARNING() + +#else // COMPILER_MSVC + +#define MSVC_SUPPRESS_WARNING(n) +#define MSVC_PUSH_DISABLE_WARNING(n) +#define MSVC_POP_WARNING() +#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code + +#endif // COMPILER_MSVC + +#endif // BASE_COMPILER_SPECIFIC_H_ diff --git a/base/message_loop.cc b/base/message_loop.cc index bdf99f0..2b7d274 100644 --- a/base/message_loop.cc +++ b/base/message_loop.cc @@ -31,6 +31,7 @@ #include <algorithm> +#include "base/compiler_specific.h" #include "base/logging.h" #include "base/message_pump_default.h" #include "base/string_util.h" @@ -80,7 +81,7 @@ static LPTOP_LEVEL_EXCEPTION_FILTER GetTopSEHFilter() { //------------------------------------------------------------------------------ MessageLoop::MessageLoop() - : timer_manager_(this), + : ALLOW_THIS_IN_INITIALIZER_LIST(timer_manager_(this)), nestable_tasks_allowed_(true), exception_restoration_(false), state_(NULL) { diff --git a/build/SConscript.main b/build/SConscript.main index 0bef1f4..1430fd7 100644 --- a/build/SConscript.main +++ b/build/SConscript.main @@ -212,7 +212,6 @@ if env['PLATFORM'] == 'win32': '/errorReport:prompt', - '/wd4355', '/wd4503', '/wd4819', ], diff --git a/build/internal/essential.vsprops b/build/internal/essential.vsprops index 341c7b2..d7c725b 100644 --- a/build/internal/essential.vsprops +++ b/build/internal/essential.vsprops @@ -19,7 +19,7 @@ WarningLevel="3" WarnAsError="true" DebugInformationFormat="3" - DisableSpecificWarnings="4355; 4503; 4819" + DisableSpecificWarnings="4503; 4819" /> <Tool Name="VCLibrarianTool" diff --git a/net/base/base64.cc b/net/base/base64.cc index 05716f5b..63c9c47 100644 --- a/net/base/base64.cc +++ b/net/base/base64.cc @@ -29,10 +29,7 @@ #include "net/base/base64.h" -#pragma warning(push) -#pragma warning(disable: 4267) #include "third_party/modp_b64/modp_b64.h" -#pragma warning(pop) namespace net { diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc index bf7c90c..3bf93c1 100644 --- a/net/base/net_util_unittest.cc +++ b/net/base/net_util_unittest.cc @@ -97,7 +97,7 @@ TEST(NetUtilTest, FileURLConversion) { // First, we'll test that we can round-trip all of the above cases of URLs std::wstring output; - for (int i = 0; i < arraysize(round_trip_cases); i++) { + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(round_trip_cases); i++) { // convert to the file URL GURL file_url(net::FilePathToFileURL(round_trip_cases[i].file)); EXPECT_EQ(std::wstring(round_trip_cases[i].url), @@ -119,14 +119,14 @@ TEST(NetUtilTest, FileURLConversion) { {L"\\\\foo\\bar.txt", L"file://foo\\bar.txt"}, {L"C:\\foo\\bar.txt", L"file:\\\\\\c:/foo/bar.txt"}, }; - for (int i = 0; i < arraysize(url_cases); i++) { + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(url_cases); i++) { net::FileURLToFilePath(GURL(WideToUTF16(url_cases[i].url)), &output); EXPECT_EQ(std::wstring(url_cases[i].file), output); } // Here, we test that UTF-8 encoded strings get decoded properly, even when // they might be stored with wide characters - const wchar_t utf8[] = L"file:///d:/Chinese/\xe6\x89\x80\xe6\x9c\x89\xe4\xb8\xad\xe6\x96\x87\xe7\xbd\x91\xe9\xa1\xb5.doc"; + const wchar_t utf8[] = "file:///d:/Chinese/\xe6\x89\x80\xe6\x9c\x89\xe4\xb8\xad\xe6\x96\x87\xe7\xbd\x91\xe9\xa1\xb5.doc"; const wchar_t wide[] = L"D:\\Chinese\\\x6240\x6709\x4e2d\x6587\x7f51\x9875.doc"; EXPECT_TRUE(net::FileURLToFilePath(GURL(WideToUTF16(utf8)), &output)); EXPECT_EQ(std::wstring(wide), output); @@ -179,14 +179,14 @@ TEST(NetUtilTest, GetSpecificHeader) { }; // Test first with google_headers. - for (size_t i = 0; i < arraysize(tests); ++i) { + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { std::wstring result = net::GetSpecificHeader(google_headers, tests[i].header_name); EXPECT_EQ(result, tests[i].expected); } // Test again with empty headers. - for (size_t i = 0; i < arraysize(tests); ++i) { + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { std::wstring result = net::GetSpecificHeader(L"", tests[i].header_name); EXPECT_EQ(result, std::wstring()); } @@ -208,7 +208,7 @@ TEST(NetUtilTest, GetHeaderParamValue) { }; // TODO(mpcomplete): add tests for other formats of headers. - for (size_t i = 0; i < arraysize(tests); ++i) { + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { std::wstring header_value = net::GetSpecificHeader(google_headers, tests[i].header_name); std::wstring result = @@ -216,7 +216,7 @@ TEST(NetUtilTest, GetHeaderParamValue) { EXPECT_EQ(result, tests[i].expected); } - for (size_t i = 0; i < arraysize(tests); ++i) { + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { std::wstring header_value = net::GetSpecificHeader(L"", tests[i].header_name); std::wstring result = @@ -293,7 +293,7 @@ TEST(NetUtilTest, GetFileNameFromCD) { {"Content-Disposition: attachment; filename==?windows-1252?Q?caf=E3?=" "=?iso-8859-7?b?4eIucG5nCg==?=", L""}, }; - for (size_t i = 0; i < arraysize(tests); ++i) { + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { EXPECT_EQ(tests[i].expected, net::GetFileNameFromCD(tests[i].header_field)); } @@ -570,7 +570,7 @@ TEST(NetUtilTest, IDNToUnicode) { #endif }; - for (int i = 0; i < arraysize(idn_cases); i++) { + for (int i = 0; i < ARRAYSIZE_UNSAFE(idn_cases); i++) { for (int j = 0; j < arraysize(kLanguages); j++) { std::wstring output; net::IDNToUnicode(idn_cases[i].input, @@ -682,7 +682,7 @@ TEST(NetUtilTest, GetSuggestedFilename) { L"", L"test.html"}, }; - for (int i = 0; i < arraysize(test_cases); ++i) { + for (int i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { std::wstring filename = net::GetSuggestedFilename( GURL(test_cases[i].url), test_cases[i].content_disp_header, test_cases[i].default_filename); diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index f629243..dad0d85 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -31,6 +31,7 @@ #include <algorithm> +#include "base/compiler_specific.h" #include "base/message_loop.h" #include "base/pickle.h" #include "base/ref_counted.h" @@ -45,8 +46,6 @@ #include "net/http/http_transaction.h" #include "net/http/http_util.h" -#pragma warning(disable: 4355) - namespace net { // disk cache entry data indices. @@ -196,9 +195,12 @@ class HttpCache::Transaction : public HttpTransaction, read_offset_(0), effective_load_flags_(0), final_upload_progress_(0), - network_info_callback_(this, &Transaction::OnNetworkInfoAvailable), - network_read_callback_(this, &Transaction::OnNetworkReadCompleted), - cache_read_callback_(this, &Transaction::OnCacheReadCompleted) { + ALLOW_THIS_IN_INITIALIZER_LIST( + network_info_callback_(this, &Transaction::OnNetworkInfoAvailable)), + ALLOW_THIS_IN_INITIALIZER_LIST( + network_read_callback_(this, &Transaction::OnNetworkReadCompleted)), + ALLOW_THIS_IN_INITIALIZER_LIST( + cache_read_callback_(this, &Transaction::OnCacheReadCompleted)) { AddRef(); // Balanced in Destroy } |