Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7344)

Unified Diff: chrome/common/pref_service.cc

Issue 10255: Port some files in chrome/common to Linux.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/gfx/text_elider.h ('k') | chrome/common/time_format.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/pref_service.cc
===================================================================
--- chrome/common/pref_service.cc (revision 5823)
+++ chrome/common/pref_service.cc (working copy)
@@ -4,6 +4,7 @@
#include "chrome/common/pref_service.h"
+#include "base/compiler_specific.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -40,13 +41,10 @@
int bytes_written = file_util::WriteFile(tmp_file_name, data_.c_str(),
static_cast<int>(data_.length()));
if (bytes_written != -1) {
- if (!MoveFileEx(tmp_file_name.c_str(), file_name_.c_str(),
- MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING)) {
+ if (!file_util::Move(tmp_file_name, file_name_)) {
// Rename failed. Try again on the off chance someone has locked either
// file and hope we're successful the second time through.
- BOOL move_result =
- MoveFileEx(tmp_file_name.c_str(), file_name_.c_str(),
- MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
+ bool move_result = file_util::Move(tmp_file_name, file_name_);
DCHECK(move_result);
}
}
@@ -56,7 +54,7 @@
std::wstring file_name_;
std::string data_;
- DISALLOW_EVIL_CONSTRUCTORS(SaveLaterTask);
+ DISALLOW_COPY_AND_ASSIGN(SaveLaterTask);
};
// A helper function for RegisterLocalized*Pref that creates a Value* based on
@@ -75,23 +73,12 @@
}
case Value::TYPE_INTEGER: {
- int num_int = 0;
- int parsed_values = swscanf_s(resource_string.c_str(), L"%d", &num_int);
- // This is a trusted value (comes from our locale dll), so it should
- // successfully parse.
- DCHECK(parsed_values == 1);
- return Value::CreateIntegerValue(num_int);
+ return Value::CreateIntegerValue(StringToInt(resource_string));
break;
}
case Value::TYPE_REAL: {
- double num_double = 0.0;
- int parsed_values = swscanf_s(resource_string.c_str(), L"%lf",
- &num_double);
- // This is a trusted value (comes from our locale dll), so it should
- // successfully parse.
- DCHECK(parsed_values == 1);
- return Value::CreateRealValue(num_double);
+ return Value::CreateRealValue(StringToDouble(resource_string));
break;
}
@@ -121,8 +108,7 @@
: persistent_(new DictionaryValue),
transient_(new DictionaryValue),
pref_filename_(pref_filename),
-#pragma warning(suppress: 4355) // Okay to pass "this" here.
- save_preferences_factory_(this) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(save_preferences_factory_(this)) {
LoadPersistentPrefs(pref_filename_);
}
@@ -434,7 +420,7 @@
// Verify that this observer doesn't already exist.
NotificationObserverList::Iterator it(*observer_list);
NotificationObserver* existing_obs;
- while (existing_obs = it.GetNext()) {
+ while ((existing_obs = it.GetNext()) != NULL) {
DCHECK(existing_obs != obs) << path << " observer already registered";
if (existing_obs == obs)
return;
@@ -640,7 +626,7 @@
NotificationObserverList::Iterator it(*(observer_iterator->second));
NotificationObserver* observer;
- while (observer = it.GetNext()) {
+ while ((observer = it.GetNext()) != NULL) {
observer->Observe(NOTIFY_PREF_CHANGED,
Source<PrefService>(this),
Details<std::wstring>(&path_str));
@@ -653,10 +639,10 @@
PrefService::Preference::Preference(DictionaryValue* root_pref,
const wchar_t* name,
Value* default_value)
- : root_pref_(root_pref),
+ : type_(Value::TYPE_NULL),
name_(name),
default_value_(default_value),
- type_(Value::TYPE_NULL) {
+ root_pref_(root_pref) {
DCHECK(name);
if (default_value) {
« no previous file with comments | « chrome/common/gfx/text_elider.h ('k') | chrome/common/time_format.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698