Chromium Code Reviews| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_data.cc |
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_data.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_data.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eaf5533a888603a1e66f27b124949dcbdcb21c6c |
| --- /dev/null |
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_data.cc |
| @@ -0,0 +1,41 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h" |
| + |
| +#include "net/url_request/url_request.h" |
| + |
| +namespace data_reduction_proxy { |
| + |
| +const void* const kDataReductionProxyUserDataKey = |
| + &kDataReductionProxyUserDataKey; |
| + |
| +DataReductionProxyData::DataReductionProxyData() |
| + : used_data_reduction_proxy_(false), is_using_lofi_(false) {} |
| + |
| +std::unique_ptr<DataReductionProxyData> DataReductionProxyData::DeepCopy() |
| + const { |
| + std::unique_ptr<DataReductionProxyData> copy(new DataReductionProxyData()); |
| + copy->used_data_reduction_proxy_ = used_data_reduction_proxy_; |
| + copy->is_using_lofi_ = is_using_lofi_; |
| + return copy; |
| +} |
| + |
| +DataReductionProxyData* DataReductionProxyData::DataForRequest( |
| + net::URLRequest* request, |
|
tbansal1
2016/04/27 23:44:48
Better to pass |request| by const ref. That makes
|
| + bool add_if_not_exist) { |
| + if (!request) |
| + return nullptr; |
| + DataReductionProxyData* data = static_cast<DataReductionProxyData*>( |
| + request->GetUserData(kDataReductionProxyUserDataKey)); |
| + if (data) |
| + return data; |
| + if (!add_if_not_exist) |
| + return nullptr; |
| + data = new DataReductionProxyData(); |
| + request->SetUserData(kDataReductionProxyUserDataKey, data); |
| + return data; |
| +} |
| + |
| +} // namespace data_reduction_proxy |