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

Side by Side Diff: net/tools/dump_cache/upgrade.cc

Issue 261045: Start migrating the disk cache to using FilePath. (Closed)
Patch Set: rebase Created 11 years, 2 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 | « net/tools/crash_cache/crash_cache.cc ('k') | no next file » | 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) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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/file_path.h"
5 #include "base/logging.h" 6 #include "base/logging.h"
6 #include "base/message_loop.h" 7 #include "base/message_loop.h"
7 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
8 #include "base/string_util.h" 9 #include "base/string_util.h"
9 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
10 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
11 #include "net/disk_cache/backend_impl.h" 12 #include "net/disk_cache/backend_impl.h"
12 #include "net/disk_cache/entry_impl.h" 13 #include "net/disk_cache/entry_impl.h"
13 #include "net/http/http_cache.h" 14 #include "net/http/http_cache.h"
14 #include "net/http/http_response_headers.h" 15 #include "net/http/http_response_headers.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 295 }
295 } 296 }
296 297
297 bool MasterSM::DoInit() { 298 bool MasterSM::DoInit() {
298 DEBUGMSG("Master DoInit\n"); 299 DEBUGMSG("Master DoInit\n");
299 DCHECK(state_ == MASTER_INITIAL); 300 DCHECK(state_ == MASTER_INITIAL);
300 301
301 if (dump_to_disk_) { 302 if (dump_to_disk_) {
302 writer_ = new DiskDumper(path_); 303 writer_ = new DiskDumper(path_);
303 } else { 304 } else {
304 cache_.reset(new disk_cache::BackendImpl(path_)); 305 cache_.reset(new disk_cache::BackendImpl(FilePath::FromWStringHack(path_)));
305 if (!cache_->Init()) { 306 if (!cache_->Init()) {
306 printf("Unable to initialize new files\n"); 307 printf("Unable to initialize new files\n");
307 return false; 308 return false;
308 } 309 }
309 writer_ = new CacheDumper(cache_.get()); 310 writer_ = new CacheDumper(cache_.get());
310 } 311 }
311 if (!writer_) 312 if (!writer_)
312 return false; 313 return false;
313 314
314 copied_entries_ = 0; 315 copied_entries_ = 0;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 printf("Unexpected failure\n"); 503 printf("Unexpected failure\n");
503 SendQuit(); 504 SendQuit();
504 } 505 }
505 506
506 // ----------------------------------------------------------------------- 507 // -----------------------------------------------------------------------
507 508
508 class SlaveSM : public BaseSM { 509 class SlaveSM : public BaseSM {
509 public: 510 public:
510 SlaveSM(const std::wstring& path, HANDLE channel) 511 SlaveSM(const std::wstring& path, HANDLE channel)
511 : BaseSM(channel), iterator_(NULL) { 512 : BaseSM(channel), iterator_(NULL) {
512 cache_.reset(new disk_cache::BackendImpl(path)); 513 cache_.reset(new disk_cache::BackendImpl(FilePath::FromWStringHack(path)));
513 if (!cache_->Init()) { 514 if (!cache_->Init()) {
514 printf("Unable to open cache files\n"); 515 printf("Unable to open cache files\n");
515 return; 516 return;
516 } 517 }
517 cache_->SetUpgradeMode(); 518 cache_->SetUpgradeMode();
518 } 519 }
519 virtual ~SlaveSM(); 520 virtual ~SlaveSM();
520 521
521 bool DoInit(); 522 bool DoInit();
522 virtual void OnIOCompleted(MessageLoopForIO::IOContext* context, 523 virtual void OnIOCompleted(MessageLoopForIO::IOContext* context,
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 820
820 SlaveSM slave(input_path, pipe); 821 SlaveSM slave(input_path, pipe);
821 if (!slave.DoInit()) { 822 if (!slave.DoInit()) {
822 printf("Unable to talk with the main process\n"); 823 printf("Unable to talk with the main process\n");
823 return -1; 824 return -1;
824 } 825 }
825 826
826 loop.Run(); 827 loop.Run();
827 return 0; 828 return 0;
828 } 829 }
OLDNEW
« no previous file with comments | « net/tools/crash_cache/crash_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698