| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/loader/chrome_navigation_data.h" | 5 #include "chrome/browser/loader/chrome_navigation_data.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
| 7 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data
.h" | 8 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data
.h" |
| 8 #include "net/url_request/url_request.h" | 9 #include "net/url_request/url_request.h" |
| 9 | 10 |
| 10 const void* const kChromeNavigationDataUserDataKey = | 11 const void* const kChromeNavigationDataUserDataKey = |
| 11 &kChromeNavigationDataUserDataKey; | 12 &kChromeNavigationDataUserDataKey; |
| 12 | 13 |
| 13 ChromeNavigationData::ChromeNavigationData() {} | 14 ChromeNavigationData::ChromeNavigationData() {} |
| 14 | 15 |
| 15 ChromeNavigationData::~ChromeNavigationData() {} | 16 ChromeNavigationData::~ChromeNavigationData() {} |
| 16 | 17 |
| 17 ChromeNavigationData* ChromeNavigationData::GetDataAndCreateIfNecessary( | 18 ChromeNavigationData* ChromeNavigationData::GetDataAndCreateIfNecessary( |
| 18 net::URLRequest* request) { | 19 net::URLRequest* request) { |
| 19 if (!request) | 20 if (!request) |
| 20 return nullptr; | 21 return nullptr; |
| 21 ChromeNavigationData* data = static_cast<ChromeNavigationData*>( | 22 ChromeNavigationData* data = static_cast<ChromeNavigationData*>( |
| 22 request->GetUserData(kChromeNavigationDataUserDataKey)); | 23 request->GetUserData(kChromeNavigationDataUserDataKey)); |
| 23 if (data) | 24 if (data) |
| 24 return data; | 25 return data; |
| 25 data = new ChromeNavigationData(); | 26 data = new ChromeNavigationData(); |
| 26 request->SetUserData(kChromeNavigationDataUserDataKey, data); | 27 request->SetUserData(kChromeNavigationDataUserDataKey, |
| 28 base::WrapUnique(data)); |
| 27 return data; | 29 return data; |
| 28 } | 30 } |
| 29 | 31 |
| 30 std::unique_ptr<content::NavigationData> ChromeNavigationData::Clone() const { | 32 std::unique_ptr<content::NavigationData> ChromeNavigationData::Clone() const { |
| 31 std::unique_ptr<ChromeNavigationData> copy(new ChromeNavigationData()); | 33 std::unique_ptr<ChromeNavigationData> copy(new ChromeNavigationData()); |
| 32 if (data_reduction_proxy_data_) | 34 if (data_reduction_proxy_data_) |
| 33 copy->SetDataReductionProxyData(data_reduction_proxy_data_->DeepCopy()); | 35 copy->SetDataReductionProxyData(data_reduction_proxy_data_->DeepCopy()); |
| 34 return std::move(copy); | 36 return std::move(copy); |
| 35 } | 37 } |
| OLD | NEW |