Index: chrome/browser/extensions/api/sessions/foreign_session_id.cc |
diff --git a/net/quic/crypto/source_address_token.cc b/chrome/browser/extensions/api/sessions/foreign_session_id.cc |
similarity index 22% |
copy from net/quic/crypto/source_address_token.cc |
copy to chrome/browser/extensions/api/sessions/foreign_session_id.cc |
index d15afebf2a75557f30c6a9a3b724c7cfc1193c44..ab991fd9359df66421065f287801e5d7a87d80c9 100644 |
--- a/net/quic/crypto/source_address_token.cc |
+++ b/chrome/browser/extensions/api/sessions/foreign_session_id.cc |
@@ -2,45 +2,33 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "net/quic/crypto/source_address_token.h" |
- |
-#include <vector> |
+#include "chrome/browser/extensions/api/sessions/foreign_session_id.h" |
#include "base/strings/string_number_conversions.h" |
-#include "base/strings/string_split.h" |
-using std::string; |
-using std::vector; |
+namespace extensions { |
-namespace net { |
+const char kIdSeparator = '.'; |
-SourceAddressToken::SourceAddressToken() { |
+ForeignSessionId::ForeignSessionId(const std::string& session_tag, int id) |
+ : session_tag_(session_tag), id_(id) { |
} |
-SourceAddressToken::~SourceAddressToken() { |
+ForeignSessionId::ForeignSessionId(const std::string& foreign_session_string) { |
+ if (IsForeignSessionId(foreign_session_string)) { |
+ std::size_t separator = foreign_session_string.find(kIdSeparator); |
+ session_tag_ = foreign_session_string.substr(0, separator); |
+ base::StringToInt(foreign_session_string.substr(separator + 1), &id_); |
+ } |
} |
-string SourceAddressToken::SerializeAsString() const { |
- return ip_ + " " + base::Int64ToString(timestamp_); |
+// static |
+bool ForeignSessionId::IsForeignSessionId(const std::string& id) { |
+ return id.find(kIdSeparator) != std::string::npos; |
} |
-bool SourceAddressToken::ParseFromArray(const char* plaintext, |
- size_t plaintext_length) { |
- string data(plaintext, plaintext_length); |
- vector<string> results; |
- base::SplitString(data, ' ', &results); |
- if (results.size() < 2) { |
- return false; |
- } |
- |
- int64 timestamp; |
- if (!base::StringToInt64(results[1], ×tamp)) { |
- return false; |
- } |
- |
- ip_ = results[0]; |
- timestamp_ = timestamp; |
- return true; |
+std::string ForeignSessionId::ToString() { |
+ return (session_tag_ + kIdSeparator + base::IntToString(id_)); |
not at google - send to devlin
2013/08/12 23:51:34
use base::StringPrintf instead
Kristen Dwan
2013/08/15 07:11:56
Done.
|
} |
-} // namespace net |
+} // namespace extensions |