OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/supervised_user/experimental/supervised_user_blacklist.
h" | 5 #include "chrome/browser/supervised_user/experimental/supervised_user_blacklist.
h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <fstream> | 9 #include <fstream> |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return std::binary_search(host_hashes_.begin(), host_hashes_.end(), hash); | 68 return std::binary_search(host_hashes_.begin(), host_hashes_.end(), hash); |
69 } | 69 } |
70 | 70 |
71 size_t SupervisedUserBlacklist::GetEntryCount() const { | 71 size_t SupervisedUserBlacklist::GetEntryCount() const { |
72 return host_hashes_.size(); | 72 return host_hashes_.size(); |
73 } | 73 } |
74 | 74 |
75 void SupervisedUserBlacklist::ReadFromFile(const base::FilePath& path, | 75 void SupervisedUserBlacklist::ReadFromFile(const base::FilePath& path, |
76 const base::Closure& done_callback) { | 76 const base::Closure& done_callback) { |
77 base::PostTaskAndReplyWithResult( | 77 base::PostTaskAndReplyWithResult( |
78 BrowserThread::GetBlockingPool(), | 78 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( |
| 79 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN).get(), |
79 FROM_HERE, | 80 FROM_HERE, |
80 base::Bind(&ReadFromBinaryFileOnFileThread, path), | 81 base::Bind(&ReadFromBinaryFileOnFileThread, path), |
81 base::Bind(&SupervisedUserBlacklist::OnReadFromFileCompleted, | 82 base::Bind(&SupervisedUserBlacklist::OnReadFromFileCompleted, |
82 weak_ptr_factory_.GetWeakPtr(), | 83 weak_ptr_factory_.GetWeakPtr(), |
83 done_callback)); | 84 done_callback)); |
84 } | 85 } |
85 | 86 |
86 void SupervisedUserBlacklist::OnReadFromFileCompleted( | 87 void SupervisedUserBlacklist::OnReadFromFileCompleted( |
87 const base::Closure& done_callback, | 88 const base::Closure& done_callback, |
88 scoped_ptr<std::vector<Hash> > host_hashes) { | 89 scoped_ptr<std::vector<Hash> > host_hashes) { |
89 host_hashes_.swap(*host_hashes); | 90 host_hashes_.swap(*host_hashes); |
90 LOG_IF(WARNING, host_hashes_.empty()) << "Got empty blacklist"; | 91 LOG_IF(WARNING, host_hashes_.empty()) << "Got empty blacklist"; |
91 | 92 |
92 if (!done_callback.is_null()) | 93 if (!done_callback.is_null()) |
93 done_callback.Run(); | 94 done_callback.Run(); |
94 } | 95 } |
OLD | NEW |