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

Side by Side Diff: media/blink/webcontentdecryptionmodulesession_impl.cc

Issue 1200053004: Move more string_util functions to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 | « media/base/mime_util.cc ('k') | net/base/data_url.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "webcontentdecryptionmodulesession_impl.h" 5 #include "webcontentdecryptionmodulesession_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // passing it to the CDM. At a minimum, this should include checking that 163 // passing it to the CDM. At a minimum, this should include checking that
164 // the length and value (e.g. alphanumeric) are reasonable. 164 // the length and value (e.g. alphanumeric) are reasonable.
165 if (!base::IsStringASCII(session_id)) 165 if (!base::IsStringASCII(session_id))
166 return false; 166 return false;
167 167
168 sanitized_session_id->assign(base::UTF16ToASCII(session_id)); 168 sanitized_session_id->assign(base::UTF16ToASCII(session_id));
169 if (sanitized_session_id->length() > limits::kMaxSessionIdLength) 169 if (sanitized_session_id->length() > limits::kMaxSessionIdLength)
170 return false; 170 return false;
171 171
172 for (const char c : *sanitized_session_id) { 172 for (const char c : *sanitized_session_id) {
173 if (!IsAsciiAlpha(c) && !IsAsciiDigit(c)) 173 if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c))
174 return false; 174 return false;
175 } 175 }
176 176
177 return true; 177 return true;
178 } 178 }
179 179
180 static bool SanitizeResponse(const std::string& key_system, 180 static bool SanitizeResponse(const std::string& key_system,
181 const uint8* response, 181 const uint8* response,
182 size_t response_length, 182 size_t response_length,
183 std::vector<uint8>* sanitized_response) { 183 std::vector<uint8>* sanitized_response) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 return blink::WebContentDecryptionModuleResult::SessionNotFound; 416 return blink::WebContentDecryptionModuleResult::SessionNotFound;
417 417
418 DCHECK(session_id_.empty()) << "Session ID may not be changed once set."; 418 DCHECK(session_id_.empty()) << "Session ID may not be changed once set.";
419 session_id_ = session_id; 419 session_id_ = session_id;
420 return adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr()) 420 return adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr())
421 ? blink::WebContentDecryptionModuleResult::NewSession 421 ? blink::WebContentDecryptionModuleResult::NewSession
422 : blink::WebContentDecryptionModuleResult::SessionAlreadyExists; 422 : blink::WebContentDecryptionModuleResult::SessionAlreadyExists;
423 } 423 }
424 424
425 } // namespace media 425 } // namespace media
OLDNEW
« no previous file with comments | « media/base/mime_util.cc ('k') | net/base/data_url.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698