summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-17 16:45:34 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-17 16:45:34 +0000
commitbc9147a10c7287f285ddc1c246cc9d38cd5987c4 (patch)
tree0e8516815d0fd31b439a4cebe4baf8e9e94c98d6 /chrome
parentc12bf1a1aa1a24d7f516b7e76428518c594d7da5 (diff)
downloadchromium_src-bc9147a10c7287f285ddc1c246cc9d38cd5987c4.zip
chromium_src-bc9147a10c7287f285ddc1c246cc9d38cd5987c4.tar.gz
chromium_src-bc9147a10c7287f285ddc1c246cc9d38cd5987c4.tar.bz2
Some initial work on compiling chrome/common/ on Linux.
Patch from Pawel Hajdan Jr. BUG=2410 Review URL: http://codereview.chromium.org/2929 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2311 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/SConscript2
-rw-r--r--chrome/common/SConscript230
-rw-r--r--chrome/common/debug_flags.cc2
-rw-r--r--chrome/common/gfx/color_utils.cc8
-rw-r--r--chrome/common/jpeg_codec.cc2
-rw-r--r--chrome/common/json_value_serializer.cc39
-rw-r--r--chrome/common/libxml_utils.cc11
-rw-r--r--chrome/common/pref_member.h19
-rw-r--r--chrome/common/slide_animation.cc2
-rw-r--r--chrome/common/stl_util-inl.h6
10 files changed, 162 insertions, 159 deletions
diff --git a/chrome/SConscript b/chrome/SConscript
index 149cbf4..7340ae4 100644
--- a/chrome/SConscript
+++ b/chrome/SConscript
@@ -425,6 +425,7 @@ if env['PLATFORM'] == 'win32':
sconscript_files = [
+ 'common/SConscript',
'$THIRD_PARTY_DIR/sqlite/SConscript',
]
@@ -435,7 +436,6 @@ if env['PLATFORM'] == 'win32':
'app/theme/SConscript',
'browser/SConscript',
'browser/views/SConscript',
- 'common/SConscript',
'installer/mini_installer/SConscript',
'installer/setup/SConscript',
'installer/util/SConscript',
diff --git a/chrome/common/SConscript b/chrome/common/SConscript
index f21d52d..d5f7f5d3 100644
--- a/chrome/common/SConscript
+++ b/chrome/common/SConscript
@@ -15,11 +15,15 @@ env.Prepend(
CPPDEFINES = [
'U_STATIC_IMPLEMENTATION',
],
- CCFLAGS = [
- '/TP',
- ],
)
+if env['PLATFORM'] == 'win32':
+ env.Prepend(
+ CCFLAGS = [
+ '/TP',
+ ],
+ )
+
env.Append(
CPPPATH = [
'third_party/wtl/include',
@@ -42,72 +46,83 @@ env.Append(
],
)
-input_files = [
- 'animation.cc',
- 'child_process.cc',
- 'chrome_constants.cc',
- 'chrome_counters.cc',
- 'chrome_paths.cc',
- 'chrome_plugin_lib.cc',
- 'chrome_plugin_util.cc',
- 'chrome_process_filter.cc',
- 'chrome_switches.cc',
- 'classfactory.cc',
- 'clipboard_service.cc',
- 'common_glue.cc',
- 'debug_flags.cc',
- 'drag_drop_types.cc',
- 'env_util.cc',
- 'env_vars.cc',
- 'gfx/chrome_canvas.cc',
- 'gfx/chrome_font.cc',
- 'gfx/color_utils.cc',
- 'gfx/emf.cc',
- 'gfx/icon_util.cc',
- 'gfx/path.cc',
- 'gfx/url_elider.cc',
- 'ipc_channel.cc',
- 'ipc_channel_proxy.cc',
- 'ipc_logging.cc',
- 'ipc_message.cc',
- 'ipc_message_utils.cc',
- 'ipc_sync_channel.cc',
- 'ipc_sync_message.cc',
- 'jpeg_codec.cc',
- 'json_value_serializer.cc',
- 'jstemplate_builder.cc',
- 'l10n_util.cc',
- 'libxml_utils.cc',
- 'logging_chrome.cc',
- 'message_router.cc',
- 'net/cookie_monster_sqlite.cc',
- 'net/url_request_intercept_job.cc',
- 'notification_service.cc',
- 'os_exchange_data.cc',
- 'plugin_messages.cc',
- 'pref_member.cc',
- 'pref_names.cc',
- 'pref_service.cc',
- 'process_watcher.cc',
- 'rand_util.cc',
- 'render_messages.cc',
- 'resource_bundle.cc',
- 'resource_dispatcher.cc',
- 'security_filter_peer.cc',
- 'slide_animation.cc',
- 'sqlite_compiled_statement.cc',
- 'sqlite_utils.cc',
- 'task_queue.cc',
- 'throb_animation.cc',
- 'thumbnail_score.cc',
- 'time_format.cc',
- 'visitedlink_common.cc',
- 'win_safe_util.cc',
- 'win_util.cc',
- 'worker_thread_ticker.cc',
-]
-
-env.ChromeStaticLibrary('common', input_files)
+input_files = []
+
+if env['PLATFORM'] in ('posix', 'win32'):
+ # TODO(port): Port to Mac.
+ input_files.extend([
+ 'chrome_constants.cc',
+ 'chrome_counters.cc',
+ 'chrome_switches.cc',
+ 'debug_flags.cc',
+ 'env_vars.cc',
+ 'gfx/color_utils.cc',
+ 'jpeg_codec.cc',
+ 'json_value_serializer.cc',
+ 'libxml_utils.cc',
+ 'net/cookie_monster_sqlite.cc',
+ 'notification_service.cc',
+ 'pref_member.cc',
+ 'pref_names.cc',
+ 'slide_animation.cc',
+ 'sqlite_compiled_statement.cc',
+ 'task_queue.cc',
+ 'throb_animation.cc',
+ 'thumbnail_score.cc',
+ 'visitedlink_common.cc',
+ ])
+
+if env['PLATFORM'] == 'win32':
+ # TODO(port): Port these.
+ input_files.extend([
+ 'animation.cc',
+ 'child_process.cc',
+ 'chrome_paths.cc',
+ 'chrome_plugin_lib.cc',
+ 'chrome_plugin_util.cc',
+ 'chrome_process_filter.cc',
+ 'classfactory.cc',
+ 'clipboard_service.cc',
+ 'common_glue.cc',
+ 'drag_drop_types.cc',
+ 'env_util.cc',
+ 'gfx/chrome_canvas.cc',
+ 'gfx/chrome_font.cc',
+ 'gfx/emf.cc',
+ 'gfx/icon_util.cc',
+ 'gfx/path.cc',
+ 'gfx/url_elider.cc',
+ 'ipc_channel.cc',
+ 'ipc_channel_proxy.cc',
+ 'ipc_logging.cc',
+ 'ipc_message.cc',
+ 'ipc_message_utils.cc',
+ 'ipc_sync_channel.cc',
+ 'ipc_sync_message.cc',
+ 'jstemplate_builder.cc',
+ 'l10n_util.cc',
+ 'logging_chrome.cc',
+ 'message_router.cc',
+ 'net/url_request_intercept_job.cc',
+ 'os_exchange_data.cc',
+ 'plugin_messages.cc',
+ 'pref_service.cc',
+ 'process_watcher.cc',
+ 'rand_util.cc',
+ 'render_messages.cc',
+ 'resource_bundle.cc',
+ 'resource_dispatcher.cc',
+ 'security_filter_peer.cc',
+ 'sqlite_utils.cc',
+ 'time_format.cc',
+ 'win_safe_util.cc',
+ 'win_util.cc',
+ 'worker_thread_ticker.cc',
+ ])
+
+if env['PLATFORM'] in ('posix', 'win32'):
+ # TODO(port): This should be enabled for all platforms.
+ env.ChromeStaticLibrary('common', input_files)
env_test = env_test.Clone()
@@ -127,41 +142,44 @@ env_test.Append(
],
)
-env_test.Append(
- LINKFLAGS = [
- '/INCREMENTAL',
-
- '/safeseh',
- '/dynamicbase',
- '/ignore:4199',
- '/nxcompat',
-
- '/DELAYLOAD:"dwmapi.dll"',
- '/DELAYLOAD:"uxtheme.dll"',
-
- '/DEBUG',
- '/MACHINE:X86',
- '/FIXED:No',
- ],
- LIBS = [
- 'rpcrt4.lib',
- 'shlwapi.lib',
- 'winmm.lib',
- ],
-)
-
-ipc_tests_files = [
- '$BASE_DIR/perftimer$OBJSUFFIX',
- 'ipc_fuzzing_tests.cc',
- 'ipc_tests.cc',
-]
-
-libs = [
- 'common.lib',
-]
-
-ipc_tests = env_test.ChromeTestProgram('ipc_tests', ipc_tests_files + libs)
-
-i = env_test.Install('$TARGET_ROOT', ipc_tests)
-Alias('chrome', i)
+if env_test['PLATFORM'] == 'win32':
+ env_test.Append(
+ LINKFLAGS = [
+ '/INCREMENTAL',
+
+ '/safeseh',
+ '/dynamicbase',
+ '/ignore:4199',
+ '/nxcompat',
+
+ '/DELAYLOAD:"dwmapi.dll"',
+ '/DELAYLOAD:"uxtheme.dll"',
+
+ '/DEBUG',
+ '/MACHINE:X86',
+ '/FIXED:No',
+ ],
+ LIBS = [
+ 'rpcrt4.lib',
+ 'shlwapi.lib',
+ 'winmm.lib',
+ ],
+ )
+
+if env_test['PLATFORM'] == 'win32':
+ # TODO(port): Port this.
+ ipc_tests_files = [
+ '$BASE_DIR/perftimer$OBJSUFFIX',
+ 'ipc_fuzzing_tests.cc',
+ 'ipc_tests.cc',
+ ]
+
+ libs = [
+ 'common.lib',
+ ]
+
+ ipc_tests = env_test.ChromeTestProgram('ipc_tests', ipc_tests_files + libs)
+
+ i = env_test.Install('$TARGET_ROOT', ipc_tests)
+ Alias('chrome', i)
diff --git a/chrome/common/debug_flags.cc b/chrome/common/debug_flags.cc
index 4cfe5b3..1e10b78 100644
--- a/chrome/common/debug_flags.cc
+++ b/chrome/common/debug_flags.cc
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <windows.h>
-
#include "chrome/common/debug_flags.h"
#include "base/base_switches.h"
diff --git a/chrome/common/gfx/color_utils.cc b/chrome/common/gfx/color_utils.cc
index ac1f66d..0b40436 100644
--- a/chrome/common/gfx/color_utils.cc
+++ b/chrome/common/gfx/color_utils.cc
@@ -2,9 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "build/build_config.h"
#include <math.h>
+#if defined(OS_WIN)
#include <windows.h>
+#endif
#include "chrome/common/gfx/color_utils.h"
@@ -248,7 +251,12 @@ SkColor SetColorAlpha(SkColor c, SkAlpha alpha) {
}
SkColor GetSysSkColor(int which) {
+#if defined(OS_WIN)
return gfx::COLORREFToSkColor(::GetSysColor(which));
+#else
+ NOTIMPLEMENTED();
+ return SK_ColorLTGRAY;
+#endif
}
} // namespace color_utils
diff --git a/chrome/common/jpeg_codec.cc b/chrome/common/jpeg_codec.cc
index 452c23d..08d5d45 100644
--- a/chrome/common/jpeg_codec.cc
+++ b/chrome/common/jpeg_codec.cc
@@ -514,7 +514,7 @@ SkBitmap* JPEGCodec::Decode(const unsigned char* input, size_t input_size) {
SkBitmap* bitmap = new SkBitmap();
bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h);
bitmap->allocPixels();
- memcpy(bitmap->getAddr32(0, 0), &data_vector[0], w * h * 4);
+ memcpy(bitmap->getAddr32(0, 0), &data_vector[0], data_length);
return bitmap;
}
diff --git a/chrome/common/json_value_serializer.cc b/chrome/common/json_value_serializer.cc
index a50ed11..b07fb29 100644
--- a/chrome/common/json_value_serializer.cc
+++ b/chrome/common/json_value_serializer.cc
@@ -4,6 +4,7 @@
#include "chrome/common/json_value_serializer.h"
+#include "base/file_util.h"
#include "base/json_reader.h"
#include "base/json_writer.h"
#include "base/string_util.h"
@@ -37,41 +38,21 @@ bool JSONFileValueSerializer::Serialize(const Value& root) {
if (!result)
return false;
- FILE* file = NULL;
- _wfopen_s(&file, json_file_path_.c_str(), L"wb");
- if (!file)
+ int data_size = static_cast<int>(json_string.size());
+ if (file_util::WriteFile(json_file_path_,
+ json_string.data(),
+ data_size) != data_size)
return false;
- size_t amount_written =
- fwrite(json_string.data(), 1, json_string.size(), file);
- fclose(file);
-
- return amount_written == json_string.size();
+ return true;
}
bool JSONFileValueSerializer::Deserialize(Value** root) {
- FILE* file = NULL;
- _wfopen_s(&file, json_file_path_.c_str(), L"rb");
- if (!file)
- return false;
-
- fseek(file, 0, SEEK_END);
- size_t file_size = ftell(file);
- rewind(file);
-
- bool result = false;
std::string json_string;
- size_t chars_read = fread(
- // WriteInto assumes the last character is a null, and it's not in this
- // case, so we need to add 1 to our size to ensure the last character
- // doesn't get cut off.
- WriteInto(&json_string, file_size + 1), 1, file_size, file);
- if (chars_read == file_size) {
- JSONStringValueSerializer serializer(json_string);
- result = serializer.Deserialize(root);
+ if (!file_util::ReadFileToString(json_file_path_, &json_string)) {
+ return false;
}
-
- fclose(file);
- return result;
+ JSONStringValueSerializer serializer(json_string);
+ return serializer.Deserialize(root);
}
diff --git a/chrome/common/libxml_utils.cc b/chrome/common/libxml_utils.cc
index 99362ee..06fbead 100644
--- a/chrome/common/libxml_utils.cc
+++ b/chrome/common/libxml_utils.cc
@@ -3,7 +3,10 @@
// found in the LICENSE file.
#include "chrome/common/libxml_utils.h"
+
+#include "base/compiler_specific.h"
#include "base/logging.h"
+#include "base/string_util.h"
#include "libxml/xmlreader.h"
@@ -17,8 +20,8 @@ std::string XmlStringToStdString(const xmlChar* xmlstring) {
XmlReader::XmlReader()
: reader_(NULL),
-#pragma warning(suppress: 4355) // Okay to pass "this" here.
- error_func_(this, &XmlReader::GenericErrorCallback) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ error_func_(this, &XmlReader::GenericErrorCallback)) {
}
XmlReader::~XmlReader() {
@@ -30,11 +33,9 @@ XmlReader::~XmlReader() {
const char* msg, ...) {
va_list args;
va_start(args, msg);
- char buffer[1 << 9];
- vsnprintf_s(buffer, arraysize(buffer), _TRUNCATE, msg, args);
XmlReader* reader = static_cast<XmlReader*>(context);
- reader->errors_.append(buffer);
+ reader->errors_.append(StringPrintf(msg, args));
}
bool XmlReader::Load(const std::string& input) {
diff --git a/chrome/common/pref_member.h b/chrome/common/pref_member.h
index d7377b6..9b5c70f 100644
--- a/chrome/common/pref_member.h
+++ b/chrome/common/pref_member.h
@@ -53,14 +53,15 @@ class PrefMemberBase : public NotificationObserver {
const std::wstring& pref_name() const { return pref_name_; }
PrefService* prefs() { return prefs_; }
- protected:
- bool is_synced_;
- bool setting_value_;
-
+ // Ordered the members to compact the class instance.
private:
std::wstring pref_name_;
- PrefService* prefs_;
NotificationObserver* observer_;
+ PrefService* prefs_;
+
+ protected:
+ bool is_synced_;
+ bool setting_value_;
};
} // namespace subtle
@@ -120,7 +121,7 @@ class PrefMember : public subtle::PrefMemberBase {
class BooleanPrefMember : public PrefMember<bool> {
public:
- BooleanPrefMember() : PrefMember() { }
+ BooleanPrefMember() : PrefMember<bool>() { }
virtual ~BooleanPrefMember() { }
protected:
@@ -133,7 +134,7 @@ class BooleanPrefMember : public PrefMember<bool> {
class IntegerPrefMember : public PrefMember<int> {
public:
- IntegerPrefMember() : PrefMember() { }
+ IntegerPrefMember() : PrefMember<int>() { }
virtual ~IntegerPrefMember() { }
protected:
@@ -146,7 +147,7 @@ class IntegerPrefMember : public PrefMember<int> {
class RealPrefMember : public PrefMember<double> {
public:
- RealPrefMember() : PrefMember() { }
+ RealPrefMember() : PrefMember<double>() { }
virtual ~RealPrefMember() { }
protected:
@@ -159,7 +160,7 @@ class RealPrefMember : public PrefMember<double> {
class StringPrefMember : public PrefMember<std::wstring> {
public:
- StringPrefMember() : PrefMember() { }
+ StringPrefMember() : PrefMember<std::wstring>() { }
virtual ~StringPrefMember() { }
protected:
diff --git a/chrome/common/slide_animation.cc b/chrome/common/slide_animation.cc
index 47a48c6..67d4023 100644
--- a/chrome/common/slide_animation.cc
+++ b/chrome/common/slide_animation.cc
@@ -15,11 +15,11 @@ static const int kDefaultDurationMs = 120;
SlideAnimation::SlideAnimation(AnimationDelegate* target)
: Animation(kDefaultFramerateHz, target),
target_(target),
+ tween_type_(EASE_OUT),
showing_(false),
value_start_(0),
value_end_(0),
value_current_(0),
- tween_type_(EASE_OUT),
slide_duration_(kDefaultDurationMs) {
}
diff --git a/chrome/common/stl_util-inl.h b/chrome/common/stl_util-inl.h
index 27587ca..7c4983a 100644
--- a/chrome/common/stl_util-inl.h
+++ b/chrome/common/stl_util-inl.h
@@ -441,12 +441,8 @@ template<typename T>
std::vector<T> SetToVector(const std::set<T>& values) {
std::vector<T> result;
result.reserve(values.size());
- std::set<T>::const_iterator end = values.end();
- for (std::set<T>::const_iterator itr = values.begin(); itr != end; ++itr) {
- result.push_back(*itr);
- }
+ result.insert(result.begin(), values.begin(), values.end());
return result;
}
#endif // CHROME_COMMON_STL_UTIL_INL_H__
-