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

Side by Side Diff: chromeos/printing/ppd_cache.cc

Issue 2545663002: Hookup the PpdProvider in the printer setup flow. (Closed)
Patch Set: Created 4 years 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 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/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 ret = contents_path; 61 ret = contents_path;
62 break; 62 break;
63 } 63 }
64 } 64 }
65 return ret; 65 return ret;
66 } 66 }
67 67
68 base::Optional<base::FilePath> Store( 68 base::Optional<base::FilePath> Store(
69 const Printer::PpdReference& reference, 69 const Printer::PpdReference& reference,
70 const std::string& ppd_contents) override { 70 const std::string& ppd_contents) override {
71 VLOG(1) << "Storing ppd";
Carlson 2016/12/01 01:58:44 Reminder to remove this logging.
skau 2016/12/01 21:45:12 Done.
71 base::ThreadRestrictions::AssertIOAllowed(); 72 base::ThreadRestrictions::AssertIOAllowed();
72 if (!EnsureCacheDirectoryExists()) { 73 if (!EnsureCacheDirectoryExists()) {
73 return base::nullopt; 74 return base::nullopt;
74 } 75 }
75 base::Optional<base::FilePath> ret; 76 base::Optional<base::FilePath> ret;
76 base::FilePath contents_path = 77 base::FilePath contents_path =
77 GetCachePathBase(reference).AddExtension(".ppd"); 78 GetCachePathBase(reference).AddExtension(".ppd");
78 if (IsGZipped(ppd_contents)) { 79 if (IsGZipped(ppd_contents)) {
80 VLOG(1) << "PPD is gzipped";
79 contents_path = contents_path.AddExtension(".gz"); 81 contents_path = contents_path.AddExtension(".gz");
80 } 82 }
81 if (base::WriteFile(contents_path, ppd_contents.data(), 83 if (base::WriteFile(contents_path, ppd_contents.data(),
82 ppd_contents.size()) == 84 ppd_contents.size()) ==
83 static_cast<int>(ppd_contents.size())) { 85 static_cast<int>(ppd_contents.size())) {
86 VLOG(1) << "Stored at path: " << contents_path.value();
84 ret = contents_path; 87 ret = contents_path;
85 } else { 88 } else {
86 LOG(ERROR) << "Failed to write " << contents_path.LossyDisplayName(); 89 LOG(ERROR) << "Failed to write " << contents_path.LossyDisplayName();
87 // Try to clean up the file, as it may have partial contents. Note that 90 // Try to clean up the file, as it may have partial contents. Note that
88 // DeleteFile(nonexistant file) should return true, so failure here means 91 // DeleteFile(nonexistant file) should return true, so failure here means
89 // something is exceptionally hosed. 92 // something is exceptionally hosed.
90 if (!base::DeleteFile(contents_path, false)) { 93 if (!base::DeleteFile(contents_path, false)) {
91 LOG(ERROR) << "Failed to cleanup partially-written file " 94 LOG(ERROR) << "Failed to cleanup partially-written file "
92 << contents_path.LossyDisplayName(); 95 << contents_path.LossyDisplayName();
93 return ret; 96 return ret;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } // namespace 295 } // namespace
293 296
294 // static 297 // static
295 std::unique_ptr<PpdCache> PpdCache::Create(const base::FilePath& cache_base_dir, 298 std::unique_ptr<PpdCache> PpdCache::Create(const base::FilePath& cache_base_dir,
296 const PpdCache::Options& options) { 299 const PpdCache::Options& options) {
297 return base::MakeUnique<PpdCacheImpl>(cache_base_dir, options); 300 return base::MakeUnique<PpdCacheImpl>(cache_base_dir, options);
298 } 301 }
299 302
300 } // namespace printing 303 } // namespace printing
301 } // namespace chromeos 304 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698