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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
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"
(...skipping 11 matching lines...) Expand all
22 SimpleCacheDumper::SimpleCacheDumper(base::FilePath input_path, 22 SimpleCacheDumper::SimpleCacheDumper(base::FilePath input_path,
23 base::FilePath output_path) 23 base::FilePath output_path)
24 : state_(STATE_NONE), 24 : state_(STATE_NONE),
25 input_path_(input_path), 25 input_path_(input_path),
26 output_path_(output_path), 26 output_path_(output_path),
27 writer_(new DiskDumper(output_path)), 27 writer_(new DiskDumper(output_path)),
28 cache_thread_(new base::Thread("CacheThead")), 28 cache_thread_(new base::Thread("CacheThead")),
29 iter_(NULL), 29 iter_(NULL),
30 src_entry_(NULL), 30 src_entry_(NULL),
31 dst_entry_(NULL), 31 dst_entry_(NULL),
32 io_callback_(base::Bind(&SimpleCacheDumper::OnIOComplete, 32 io_callback_(
33 base::Unretained(this))), 33 base::Bind(&SimpleCacheDumper::OnIOComplete, base::Unretained(this))),
34 rv_(0) { 34 rv_(0) {
35 } 35 }
36 36
37 SimpleCacheDumper::~SimpleCacheDumper() { 37 SimpleCacheDumper::~SimpleCacheDumper() {
38 } 38 }
39 39
40 int SimpleCacheDumper::Run() { 40 int SimpleCacheDumper::Run() {
41 base::MessageLoopForIO main_message_loop; 41 base::MessageLoopForIO main_message_loop;
42 42
43 LOG(INFO) << "Reading cache from: " << input_path_.value(); 43 LOG(INFO) << "Reading cache from: " << input_path_.value();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 NULL, 132 NULL,
133 &cache_, 133 &cache_,
134 io_callback_); 134 io_callback_);
135 } 135 }
136 136
137 int SimpleCacheDumper::DoCreateCacheComplete(int rv) { 137 int SimpleCacheDumper::DoCreateCacheComplete(int rv) {
138 if (rv < 0) 138 if (rv < 0)
139 return rv; 139 return rv;
140 140
141 reinterpret_cast<disk_cache::BackendImpl*>(cache_.get())->SetUpgradeMode(); 141 reinterpret_cast<disk_cache::BackendImpl*>(cache_.get())->SetUpgradeMode();
142 reinterpret_cast<disk_cache::BackendImpl*>(cache_.get())->SetFlags( 142 reinterpret_cast<disk_cache::BackendImpl*>(cache_.get())
143 disk_cache::kNoRandom); 143 ->SetFlags(disk_cache::kNoRandom);
144 144
145 state_ = STATE_OPEN_ENTRY; 145 state_ = STATE_OPEN_ENTRY;
146 return OK; 146 return OK;
147 } 147 }
148 148
149 int SimpleCacheDumper::DoOpenEntry() { 149 int SimpleCacheDumper::DoOpenEntry() {
150 DCHECK(!dst_entry_); 150 DCHECK(!dst_entry_);
151 DCHECK(!src_entry_); 151 DCHECK(!src_entry_);
152 state_ = STATE_OPEN_ENTRY_COMPLETE; 152 state_ = STATE_OPEN_ENTRY_COMPLETE;
153 return cache_->OpenNextEntry(&iter_, &src_entry_, io_callback_); 153 return cache_->OpenNextEntry(&iter_, &src_entry_, io_callback_);
(...skipping 10 matching lines...) Expand all
164 return rv; 164 return rv;
165 165
166 state_ = STATE_CREATE_ENTRY; 166 state_ = STATE_CREATE_ENTRY;
167 return OK; 167 return OK;
168 } 168 }
169 169
170 int SimpleCacheDumper::DoCreateEntry() { 170 int SimpleCacheDumper::DoCreateEntry() {
171 DCHECK(!dst_entry_); 171 DCHECK(!dst_entry_);
172 state_ = STATE_CREATE_ENTRY_COMPLETE; 172 state_ = STATE_CREATE_ENTRY_COMPLETE;
173 173
174 return writer_->CreateEntry(src_entry_->GetKey(), &dst_entry_, 174 return writer_->CreateEntry(src_entry_->GetKey(), &dst_entry_, io_callback_);
175 io_callback_);
176 } 175 }
177 176
178 int SimpleCacheDumper::DoCreateEntryComplete(int rv) { 177 int SimpleCacheDumper::DoCreateEntryComplete(int rv) {
179 if (rv < 0) 178 if (rv < 0)
180 return rv; 179 return rv;
181 180
182 state_ = STATE_READ_HEADERS; 181 state_ = STATE_READ_HEADERS;
183 return OK; 182 return OK;
184 } 183 }
185 184
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 rv = DoLoop(rv); 263 rv = DoLoop(rv);
265 264
266 if (rv != ERR_IO_PENDING) { 265 if (rv != ERR_IO_PENDING) {
267 rv_ = rv; 266 rv_ = rv;
268 cache_.reset(); 267 cache_.reset();
269 base::MessageLoop::current()->Quit(); 268 base::MessageLoop::current()->Quit();
270 } 269 }
271 } 270 }
272 271
273 } // namespace net 272 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698