OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // URL filename encoder goals: | 5 // URL filename encoder goals: |
6 // | 6 // |
7 // 1. Allow URLs with arbitrary path-segment length, generating filenames | 7 // 1. Allow URLs with arbitrary path-segment length, generating filenames |
8 // with a maximum of 128 characters. | 8 // with a maximum of 128 characters. |
9 // 2. Provide a somewhat human readable filenames, for easy debugging flow. | 9 // 2. Provide a somewhat human readable filenames, for easy debugging flow. |
10 // 3. Provide reverse-mapping from filenames back to URLs. | 10 // 3. Provide reverse-mapping from filenames back to URLs. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // /very...longname/ /very...long,-/name If very...long is about 126 long. | 74 // /very...longname/ /very...long,-/name If very...long is about 126 long. |
75 | 75 |
76 // NOTE: we avoid using some classes here (like FilePath and GURL) because we | 76 // NOTE: we avoid using some classes here (like FilePath and GURL) because we |
77 // share this code with other projects externally. | 77 // share this code with other projects externally. |
78 | 78 |
79 #ifndef NET_TOOLS_DUMP_CACHE_URL_TO_FILENAME_ENCODER_H_ | 79 #ifndef NET_TOOLS_DUMP_CACHE_URL_TO_FILENAME_ENCODER_H_ |
80 #define NET_TOOLS_DUMP_CACHE_URL_TO_FILENAME_ENCODER_H_ | 80 #define NET_TOOLS_DUMP_CACHE_URL_TO_FILENAME_ENCODER_H_ |
81 | 81 |
82 #include <string> | 82 #include <string> |
83 | 83 |
84 #include "base/string_util.h" | 84 #include "base/strings/string_util.h" |
85 #include "net/tools/dump_cache/url_utilities.h" | 85 #include "net/tools/dump_cache/url_utilities.h" |
86 | 86 |
87 namespace net { | 87 namespace net { |
88 | 88 |
89 // Helper class for converting a URL into a filename. | 89 // Helper class for converting a URL into a filename. |
90 class UrlToFilenameEncoder { | 90 class UrlToFilenameEncoder { |
91 public: | 91 public: |
92 // Given a |url| and a |base_path|, returns a filename which represents this | 92 // Given a |url| and a |base_path|, returns a filename which represents this |
93 // |url|. |url| may include URL escaping such as %21 for ! | 93 // |url|. |url| may include URL escaping such as %21 for ! |
94 // |legacy_escape| indicates that this function should use the old-style | 94 // |legacy_escape| indicates that this function should use the old-style |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 static void StripDoubleSlashes(std::string* path) { | 202 static void StripDoubleSlashes(std::string* path) { |
203 const std::string doubleslash("\\\\"); | 203 const std::string doubleslash("\\\\"); |
204 const std::string escaped_doubleslash("%5C%5C"); | 204 const std::string escaped_doubleslash("%5C%5C"); |
205 ReplaceAll(path, doubleslash, escaped_doubleslash); | 205 ReplaceAll(path, doubleslash, escaped_doubleslash); |
206 } | 206 } |
207 }; | 207 }; |
208 | 208 |
209 } // namespace net | 209 } // namespace net |
210 | 210 |
211 #endif // NET_TOOLS_DUMP_CACHE_URL_TO_FILENAME_ENCODER_H_ | 211 #endif // NET_TOOLS_DUMP_CACHE_URL_TO_FILENAME_ENCODER_H_ |
OLD | NEW |