| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chromeos/printing/ppd_cache.h" | 5 #include "chromeos/printing/ppd_cache.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/json/json_parser.h" | 12 #include "base/json/json_parser.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "base/task_runner_util.h" | 18 #include "base/task_runner_util.h" |
| 19 #include "base/task_scheduler/post_task.h" | 19 #include "base/task_scheduler/post_task.h" |
| 20 #include "base/threading/sequenced_task_runner_handle.h" | 20 #include "base/threading/sequenced_task_runner_handle.h" |
| 21 #include "base/threading/thread_restrictions.h" | 21 #include "base/threading/thread_restrictions.h" |
| 22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 23 #include "base/values.h" | 23 #include "base/values.h" |
| 24 #include "chromeos/printing/printing_constants.h" | 24 #include "chromeos/printing/printing_constants.h" |
| 25 #include "crypto/sha2.h" | 25 #include "crypto/sha2.h" |
| 26 #include "net/base/io_buffer.h" | 26 #include "net/base/io_buffer.h" |
| 27 #include "net/filter/gzip_header.h" | 27 #include "net/filter/gzip_header.h" |
| 28 | 28 |
| 29 namespace chromeos { | 29 namespace chromeos { |
| 30 namespace printing { | |
| 31 namespace { | 30 namespace { |
| 32 | 31 |
| 33 // Return the (full) path to the file we expect to find the given key at. | 32 // Return the (full) path to the file we expect to find the given key at. |
| 34 base::FilePath FilePathForKey(const base::FilePath& base_dir, | 33 base::FilePath FilePathForKey(const base::FilePath& base_dir, |
| 35 const std::string& key) { | 34 const std::string& key) { |
| 36 std::string hashed_key = crypto::SHA256HashString(key); | 35 std::string hashed_key = crypto::SHA256HashString(key); |
| 37 return base_dir.Append(base::HexEncode(hashed_key.data(), hashed_key.size())); | 36 return base_dir.Append(base::HexEncode(hashed_key.data(), hashed_key.size())); |
| 38 } | 37 } |
| 39 | 38 |
| 40 // If the cache doesn't already exist, create it. | 39 // If the cache doesn't already exist, create it. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 DISALLOW_COPY_AND_ASSIGN(PpdCacheImpl); | 157 DISALLOW_COPY_AND_ASSIGN(PpdCacheImpl); |
| 159 }; | 158 }; |
| 160 | 159 |
| 161 } // namespace | 160 } // namespace |
| 162 | 161 |
| 163 // static | 162 // static |
| 164 scoped_refptr<PpdCache> PpdCache::Create(const base::FilePath& cache_base_dir) { | 163 scoped_refptr<PpdCache> PpdCache::Create(const base::FilePath& cache_base_dir) { |
| 165 return scoped_refptr<PpdCache>(new PpdCacheImpl(cache_base_dir)); | 164 return scoped_refptr<PpdCache>(new PpdCacheImpl(cache_base_dir)); |
| 166 } | 165 } |
| 167 | 166 |
| 168 } // namespace printing | |
| 169 } // namespace chromeos | 167 } // namespace chromeos |
| OLD | NEW |