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

Side by Side Diff: chrome/browser/chromeos/policy/cloud_external_data_store.cc

Issue 2871303004: Rename TaskRunner::RunsTasksOnCurrentThread() in //chrome (Closed)
Patch Set: fixed build error Created 3 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/chromeos/policy/cloud_external_data_store.h" 5 #include "chrome/browser/chromeos/policy/cloud_external_data_store.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 19 matching lines...) Expand all
30 CloudExternalDataStore::CloudExternalDataStore( 30 CloudExternalDataStore::CloudExternalDataStore(
31 const std::string& cache_key, 31 const std::string& cache_key,
32 scoped_refptr<base::SequencedTaskRunner> task_runner, 32 scoped_refptr<base::SequencedTaskRunner> task_runner,
33 ResourceCache* cache) 33 ResourceCache* cache)
34 : cache_key_(cache_key), 34 : cache_key_(cache_key),
35 task_runner_(task_runner), 35 task_runner_(task_runner),
36 cache_(cache) { 36 cache_(cache) {
37 } 37 }
38 38
39 CloudExternalDataStore::~CloudExternalDataStore() { 39 CloudExternalDataStore::~CloudExternalDataStore() {
40 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 40 DCHECK(task_runner_->RunsTasksInCurrentSequence());
41 } 41 }
42 42
43 void CloudExternalDataStore::Prune( 43 void CloudExternalDataStore::Prune(
44 const CloudExternalDataManager::Metadata& metadata) { 44 const CloudExternalDataManager::Metadata& metadata) {
45 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 45 DCHECK(task_runner_->RunsTasksInCurrentSequence());
46 std::set<std::string> subkeys_to_keep; 46 std::set<std::string> subkeys_to_keep;
47 for (CloudExternalDataManager::Metadata::const_iterator it = metadata.begin(); 47 for (CloudExternalDataManager::Metadata::const_iterator it = metadata.begin();
48 it != metadata.end(); ++it) { 48 it != metadata.end(); ++it) {
49 subkeys_to_keep.insert(GetSubkey(it->first, it->second.hash)); 49 subkeys_to_keep.insert(GetSubkey(it->first, it->second.hash));
50 } 50 }
51 cache_->PurgeOtherSubkeys(cache_key_, subkeys_to_keep); 51 cache_->PurgeOtherSubkeys(cache_key_, subkeys_to_keep);
52 } 52 }
53 53
54 bool CloudExternalDataStore::Store(const std::string& policy, 54 bool CloudExternalDataStore::Store(const std::string& policy,
55 const std::string& hash, 55 const std::string& hash,
56 const std::string& data) { 56 const std::string& data) {
57 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 57 DCHECK(task_runner_->RunsTasksInCurrentSequence());
58 return cache_->Store(cache_key_, GetSubkey(policy, hash), data); 58 return cache_->Store(cache_key_, GetSubkey(policy, hash), data);
59 } 59 }
60 60
61 bool CloudExternalDataStore::Load(const std::string& policy, 61 bool CloudExternalDataStore::Load(const std::string& policy,
62 const std::string& hash, 62 const std::string& hash,
63 size_t max_size, 63 size_t max_size,
64 std::string* data) { 64 std::string* data) {
65 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 65 DCHECK(task_runner_->RunsTasksInCurrentSequence());
66 const std::string subkey = GetSubkey(policy, hash); 66 const std::string subkey = GetSubkey(policy, hash);
67 if (cache_->Load(cache_key_, subkey, data)) { 67 if (cache_->Load(cache_key_, subkey, data)) {
68 if (data->size() <= max_size && crypto::SHA256HashString(*data) == hash) 68 if (data->size() <= max_size && crypto::SHA256HashString(*data) == hash)
69 return true; 69 return true;
70 // If the data is larger than allowed or does not match the expected hash, 70 // If the data is larger than allowed or does not match the expected hash,
71 // delete the entry. 71 // delete the entry.
72 cache_->Delete(cache_key_, subkey); 72 cache_->Delete(cache_key_, subkey);
73 data->clear(); 73 data->clear();
74 } 74 }
75 return false; 75 return false;
76 } 76 }
77 77
78 } // namespace policy 78 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698