| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/tools/dump_cache/simple_cache_dumper.h" | 5 #include "net/tools/dump_cache/simple_cache_dumper.h" |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" | |
| 13 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 14 #include "net/base/cache_type.h" | 13 #include "net/base/cache_type.h" |
| 15 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
| 16 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 17 #include "net/disk_cache/disk_cache.h" | 16 #include "net/disk_cache/disk_cache.h" |
| 18 #include "net/tools/dump_cache/cache_dumper.h" | 17 #include "net/tools/dump_cache/cache_dumper.h" |
| 19 | 18 |
| 20 namespace net { | 19 namespace net { |
| 21 | 20 |
| 22 SimpleCacheDumper::SimpleCacheDumper(base::FilePath input_path, | 21 SimpleCacheDumper::SimpleCacheDumper(base::FilePath input_path, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 break; | 114 break; |
| 116 } | 115 } |
| 117 } while (state_ != STATE_NONE && rv != ERR_IO_PENDING); | 116 } while (state_ != STATE_NONE && rv != ERR_IO_PENDING); |
| 118 return rv; | 117 return rv; |
| 119 } | 118 } |
| 120 | 119 |
| 121 int SimpleCacheDumper::DoCreateCache() { | 120 int SimpleCacheDumper::DoCreateCache() { |
| 122 DCHECK(!cache_); | 121 DCHECK(!cache_); |
| 123 state_ = STATE_CREATE_CACHE_COMPLETE; | 122 state_ = STATE_CREATE_CACHE_COMPLETE; |
| 124 return disk_cache::CreateCacheBackend( | 123 return disk_cache::CreateCacheBackend( |
| 125 DISK_CACHE, | 124 DISK_CACHE, CACHE_BACKEND_DEFAULT, input_path_, 0, false, |
| 126 CACHE_BACKEND_DEFAULT, | 125 cache_thread_->task_runner(), NULL, &cache_, io_callback_); |
| 127 input_path_, | |
| 128 0, | |
| 129 false, | |
| 130 cache_thread_->message_loop_proxy().get(), | |
| 131 NULL, | |
| 132 &cache_, | |
| 133 io_callback_); | |
| 134 } | 126 } |
| 135 | 127 |
| 136 int SimpleCacheDumper::DoCreateCacheComplete(int rv) { | 128 int SimpleCacheDumper::DoCreateCacheComplete(int rv) { |
| 137 if (rv < 0) | 129 if (rv < 0) |
| 138 return rv; | 130 return rv; |
| 139 | 131 |
| 140 reinterpret_cast<disk_cache::BackendImpl*>(cache_.get())->SetUpgradeMode(); | 132 reinterpret_cast<disk_cache::BackendImpl*>(cache_.get())->SetUpgradeMode(); |
| 141 reinterpret_cast<disk_cache::BackendImpl*>(cache_.get())->SetFlags( | 133 reinterpret_cast<disk_cache::BackendImpl*>(cache_.get())->SetFlags( |
| 142 disk_cache::kNoRandom); | 134 disk_cache::kNoRandom); |
| 143 | 135 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 rv = DoLoop(rv); | 255 rv = DoLoop(rv); |
| 264 | 256 |
| 265 if (rv != ERR_IO_PENDING) { | 257 if (rv != ERR_IO_PENDING) { |
| 266 rv_ = rv; | 258 rv_ = rv; |
| 267 cache_.reset(); | 259 cache_.reset(); |
| 268 base::MessageLoop::current()->Quit(); | 260 base::MessageLoop::current()->Quit(); |
| 269 } | 261 } |
| 270 } | 262 } |
| 271 | 263 |
| 272 } // namespace net | 264 } // namespace net |
| OLD | NEW |