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

Side by Side Diff: base/prefs/pref_service.cc

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 months 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 unified diff | Download patch
« no previous file with comments | « base/prefs/overlay_user_pref_store_unittest.cc ('k') | base/prefs/pref_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 base::Value* value = NULL; 464 base::Value* value = NULL;
465 if (!user_pref_store_->GetMutableValue(path, &value) || 465 if (!user_pref_store_->GetMutableValue(path, &value) ||
466 !value->IsType(type)) { 466 !value->IsType(type)) {
467 if (type == base::Value::TYPE_DICTIONARY) { 467 if (type == base::Value::TYPE_DICTIONARY) {
468 value = new base::DictionaryValue; 468 value = new base::DictionaryValue;
469 } else if (type == base::Value::TYPE_LIST) { 469 } else if (type == base::Value::TYPE_LIST) {
470 value = new base::ListValue; 470 value = new base::ListValue;
471 } else { 471 } else {
472 NOTREACHED(); 472 NOTREACHED();
473 } 473 }
474 user_pref_store_->SetValueSilently(path, value, GetWriteFlags(pref)); 474 user_pref_store_->SetValueSilently(path, make_scoped_ptr(value),
475 GetWriteFlags(pref));
475 } 476 }
476 return value; 477 return value;
477 } 478 }
478 479
479 void PrefService::ReportUserPrefChanged(const std::string& key) { 480 void PrefService::ReportUserPrefChanged(const std::string& key) {
480 DCHECK(CalledOnValidThread()); 481 DCHECK(CalledOnValidThread());
481 user_pref_store_->ReportValueChanged(key, GetWriteFlags(FindPreference(key))); 482 user_pref_store_->ReportValueChanged(key, GetWriteFlags(FindPreference(key)));
482 } 483 }
483 484
484 void PrefService::SetUserPrefValue(const std::string& path, 485 void PrefService::SetUserPrefValue(const std::string& path,
485 base::Value* new_value) { 486 base::Value* new_value) {
486 scoped_ptr<base::Value> owned_value(new_value); 487 scoped_ptr<base::Value> owned_value(new_value);
487 DCHECK(CalledOnValidThread()); 488 DCHECK(CalledOnValidThread());
488 489
489 const Preference* pref = FindPreference(path); 490 const Preference* pref = FindPreference(path);
490 if (!pref) { 491 if (!pref) {
491 NOTREACHED() << "Trying to write an unregistered pref: " << path; 492 NOTREACHED() << "Trying to write an unregistered pref: " << path;
492 return; 493 return;
493 } 494 }
494 if (pref->GetType() != new_value->GetType()) { 495 if (pref->GetType() != new_value->GetType()) {
495 NOTREACHED() << "Trying to set pref " << path 496 NOTREACHED() << "Trying to set pref " << path
496 << " of type " << pref->GetType() 497 << " of type " << pref->GetType()
497 << " to value of type " << new_value->GetType(); 498 << " to value of type " << new_value->GetType();
498 return; 499 return;
499 } 500 }
500 501
501 user_pref_store_->SetValue(path, owned_value.release(), GetWriteFlags(pref)); 502 user_pref_store_->SetValue(path, owned_value.Pass(), GetWriteFlags(pref));
502 } 503 }
503 504
504 void PrefService::UpdateCommandLinePrefStore(PrefStore* command_line_store) { 505 void PrefService::UpdateCommandLinePrefStore(PrefStore* command_line_store) {
505 pref_value_store_->UpdateCommandLinePrefStore(command_line_store); 506 pref_value_store_->UpdateCommandLinePrefStore(command_line_store);
506 } 507 }
507 508
508 /////////////////////////////////////////////////////////////////////////////// 509 ///////////////////////////////////////////////////////////////////////////////
509 // PrefService::Preference 510 // PrefService::Preference
510 511
511 PrefService::Preference::Preference(const PrefService* service, 512 PrefService::Preference::Preference(const PrefService* service,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 DCHECK(found_value->IsType(default_type)); 606 DCHECK(found_value->IsType(default_type));
606 return found_value; 607 return found_value;
607 } else { 608 } else {
608 // Every registered preference has at least a default value. 609 // Every registered preference has at least a default value.
609 NOTREACHED() << "no valid value found for registered pref " << path; 610 NOTREACHED() << "no valid value found for registered pref " << path;
610 } 611 }
611 } 612 }
612 613
613 return NULL; 614 return NULL;
614 } 615 }
OLDNEW
« no previous file with comments | « base/prefs/overlay_user_pref_store_unittest.cc ('k') | base/prefs/pref_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698