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 <iostream> | 5 #include <iostream> |
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/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/utf_string_conversions.h" | |
15 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
16 #include "net/base/test_completion_callback.h" | 15 #include "net/base/test_completion_callback.h" |
17 #include "net/disk_cache/disk_cache.h" | 16 #include "net/disk_cache/disk_cache.h" |
18 #include "net/http/http_cache.h" | 17 #include "net/http/http_cache.h" |
19 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
20 #include "net/http/http_util.h" | 19 #include "net/http/http_util.h" |
21 | 20 |
22 using disk_cache::Backend; | 21 using disk_cache::Backend; |
23 using disk_cache::Entry; | 22 using disk_cache::Entry; |
24 | 23 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 124 |
126 } // namespace | 125 } // namespace |
127 | 126 |
128 int main(int argc, char* argv[]) { | 127 int main(int argc, char* argv[]) { |
129 base::AtExitManager at_exit_manager; | 128 base::AtExitManager at_exit_manager; |
130 base::MessageLoopForIO message_loop; | 129 base::MessageLoopForIO message_loop; |
131 base::CommandLine::Init(argc, argv); | 130 base::CommandLine::Init(argc, argv); |
132 const base::CommandLine& command_line = | 131 const base::CommandLine& command_line = |
133 *base::CommandLine::ForCurrentProcess(); | 132 *base::CommandLine::ForCurrentProcess(); |
134 | 133 |
135 #if defined(OS_WIN) | |
136 std::vector<std::string> args; | |
137 base::CommandLine::StringVector wide_args = command_line.GetArgs(); | |
138 for (const auto& arg : wide_args) { | |
139 args.push_back(base::WideToUTF8(arg)); | |
140 } | |
141 #else | |
142 base::CommandLine::StringVector args = command_line.GetArgs(); | 134 base::CommandLine::StringVector args = command_line.GetArgs(); |
143 #endif | |
144 if (args.size() < 3U) { | 135 if (args.size() < 3U) { |
145 PrintHelp(); | 136 PrintHelp(); |
146 return 1; | 137 return 1; |
147 } | 138 } |
148 | 139 |
149 #if defined(OS_WIN) | |
150 base::FilePath cache_path(wide_args[0]); | |
151 #else | |
152 base::FilePath cache_path(args[0]); | 140 base::FilePath cache_path(args[0]); |
153 #endif | |
154 std::string cache_backend_type(args[1]); | 141 std::string cache_backend_type(args[1]); |
155 std::string subcommand(args[2]); | 142 std::string subcommand(args[2]); |
156 | 143 |
157 net::BackendType backend_type; | 144 net::BackendType backend_type; |
158 if (cache_backend_type == "simple") { | 145 if (cache_backend_type == "simple") { |
159 backend_type = net::CACHE_BACKEND_SIMPLE; | 146 backend_type = net::CACHE_BACKEND_SIMPLE; |
160 } else if (cache_backend_type == "blockfile") { | 147 } else if (cache_backend_type == "blockfile") { |
161 backend_type = net::CACHE_BACKEND_BLOCKFILE; | 148 backend_type = net::CACHE_BACKEND_BLOCKFILE; |
162 } else { | 149 } else { |
163 std::cerr << "Unknown cache type." << std::endl; | 150 std::cerr << "Unknown cache type." << std::endl; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 return 1; | 194 return 1; |
208 } | 195 } |
209 std::string key(args[3]); | 196 std::string key(args[3]); |
210 successful_command = DeleteKey(cache_backend.get(), key); | 197 successful_command = DeleteKey(cache_backend.get(), key); |
211 } else { | 198 } else { |
212 std::cerr << "Unknown subcommand." << std::endl; | 199 std::cerr << "Unknown subcommand." << std::endl; |
213 PrintHelp(); | 200 PrintHelp(); |
214 } | 201 } |
215 return !successful_command; | 202 return !successful_command; |
216 } | 203 } |
OLD | NEW |