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

Side by Side Diff: net/base/data_url.cc

Issue 1215933004: New new versions of Starts/EndsWith and SplitString in net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@starts_with
Patch Set: Created 5 years, 5 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 | « base/strings/string_util.cc ('k') | net/base/host_mapping_rules.cc » ('j') | 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) 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 // NOTE: based loosely on mozilla's nsDataChannel.cpp 5 // NOTE: based loosely on mozilla's nsDataChannel.cpp
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "net/base/data_url.h" 9 #include "net/base/data_url.h"
10 10
(...skipping 18 matching lines...) Expand all
29 29
30 std::string::const_iterator after_colon = std::find(begin, end, ':'); 30 std::string::const_iterator after_colon = std::find(begin, end, ':');
31 if (after_colon == end) 31 if (after_colon == end)
32 return false; 32 return false;
33 ++after_colon; 33 ++after_colon;
34 34
35 std::string::const_iterator comma = std::find(after_colon, end, ','); 35 std::string::const_iterator comma = std::find(after_colon, end, ',');
36 if (comma == end) 36 if (comma == end)
37 return false; 37 return false;
38 38
39 std::vector<std::string> meta_data; 39 std::vector<std::string> meta_data =
40 std::string unparsed_meta_data(after_colon, comma); 40 base::SplitString(base::StringPiece(after_colon, comma), ";",
41 base::SplitString(unparsed_meta_data, ';', &meta_data); 41 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
42 42
43 std::vector<std::string>::iterator iter = meta_data.begin(); 43 std::vector<std::string>::iterator iter = meta_data.begin();
44 if (iter != meta_data.end()) { 44 if (iter != meta_data.end()) {
45 mime_type->swap(*iter); 45 mime_type->swap(*iter);
46 base::StringToLowerASCII(mime_type); 46 base::StringToLowerASCII(mime_type);
47 ++iter; 47 ++iter;
48 } 48 }
49 49
50 static const char kBase64Tag[] = "base64"; 50 static const char kBase64Tag[] = "base64";
51 static const char kCharsetTag[] = "charset="; 51 static const char kCharsetTag[] = "charset=";
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 temp_data.resize(length + padding_needed, '='); 129 temp_data.resize(length + padding_needed, '=');
130 } 130 }
131 return base::Base64Decode(temp_data, data); 131 return base::Base64Decode(temp_data, data);
132 } 132 }
133 133
134 temp_data.swap(*data); 134 temp_data.swap(*data);
135 return true; 135 return true;
136 } 136 }
137 137
138 } // namespace net 138 } // namespace net
OLDNEW
« no previous file with comments | « base/strings/string_util.cc ('k') | net/base/host_mapping_rules.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698