Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 //
2 // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
7 #include "Input.h"
9 #include <algorithm>
10 #include <cassert>
11 #include <cstring>
13 namespace pp
14 {
16 Input::Input() : mCount(0), mString(0)
17 {
18 }
20 Input::Input(size_t count, const char* const string[], const int length[]) :
21 mCount(count),
22 mString(string)
23 {
24 mLength.reserve(mCount);
25 for (size_t i = 0; i < mCount; ++i)
26 {
27 int len = length ? length[i] : -1;
28 mLength.push_back(len < 0 ? std::strlen(mString[i]) : len);
29 }
30 }
32 size_t Input::read(char* buf, size_t maxSize)
33 {
34 size_t nRead = 0;
35 while ((nRead < maxSize) && (mReadLoc.sIndex < mCount))
36 {
37 size_t size = mLength[mReadLoc.sIndex] - mReadLoc.cIndex;
38 size = std::min(size, maxSize);
39 std::memcpy(buf + nRead, mString[mReadLoc.sIndex] + mReadLoc.cIndex, size);
40 nRead += size;
41 mReadLoc.cIndex += size;
43 // Advance string if we reached the end of current string.
44 if (mReadLoc.cIndex == mLength[mReadLoc.sIndex])
45 {
46 ++mReadLoc.sIndex;
47 mReadLoc.cIndex = 0;
48 }
49 }
50 return nRead;
51 }
53 } // namespace pp