| 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 #ifndef CHROME_BROWSER_LOADER_CHROME_NAVIGATION_DATA_H_ | 5 #ifndef CHROME_BROWSER_LOADER_CHROME_NAVIGATION_DATA_H_ |
| 6 #define CHROME_BROWSER_LOADER_CHROME_NAVIGATION_DATA_H_ | 6 #define CHROME_BROWSER_LOADER_CHROME_NAVIGATION_DATA_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/supports_user_data.h" | 11 #include "base/supports_user_data.h" |
| 12 #include "content/public/browser/navigation_data.h" | 12 #include "content/public/browser/navigation_data.h" |
| 13 | 13 |
| 14 namespace content { |
| 15 class NavigationHandle; |
| 16 } |
| 17 |
| 14 namespace data_reduction_proxy { | 18 namespace data_reduction_proxy { |
| 15 class DataReductionProxyData; | 19 class DataReductionProxyData; |
| 16 } | 20 } |
| 17 | 21 |
| 18 namespace net { | 22 namespace net { |
| 19 class URLRequest; | 23 class URLRequest; |
| 20 } | 24 } |
| 21 | 25 |
| 26 namespace offline_pages { |
| 27 class LoadedOfflinePageInfo; |
| 28 } |
| 29 |
| 22 class ChromeNavigationData : public content::NavigationData, | 30 class ChromeNavigationData : public content::NavigationData, |
| 23 public base::SupportsUserData::Data { | 31 public base::SupportsUserData::Data { |
| 24 public: | 32 public: |
| 25 ChromeNavigationData(); | 33 ChromeNavigationData(); |
| 26 ~ChromeNavigationData() override; | 34 ~ChromeNavigationData() override; |
| 27 | 35 |
| 28 // Creates a new ChromeNavigationData that is a deep copy of the original. Any | 36 // Creates a new ChromeNavigationData that is a deep copy of the original. Any |
| 29 // changes to the original after the clone is created will not be reflected in | 37 // changes to the original after the clone is created will not be reflected in |
| 30 // the clone. | 38 // the clone. |
| 31 // |data_reduction_proxy_data_| is deep copied. | 39 // |data_reduction_proxy_data_| is deep copied. |
| 32 std::unique_ptr<content::NavigationData> Clone() const override; | 40 std::unique_ptr<content::NavigationData> Clone() const override; |
| 33 | 41 |
| 34 // Takes ownership of |data_reduction_proxy_data|. | 42 // Takes ownership of |data_reduction_proxy_data|. |
| 35 void SetDataReductionProxyData( | 43 void SetDataReductionProxyData( |
| 36 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> | 44 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> |
| 37 data_reduction_proxy_data) { | 45 data_reduction_proxy_data); |
| 38 data_reduction_proxy_data_ = std::move(data_reduction_proxy_data); | |
| 39 } | |
| 40 | 46 |
| 41 data_reduction_proxy::DataReductionProxyData* GetDataReductionProxyData() | 47 data_reduction_proxy::DataReductionProxyData* GetDataReductionProxyData() |
| 42 const { | 48 const { |
| 43 return data_reduction_proxy_data_.get(); | 49 return data_reduction_proxy_data_.get(); |
| 44 } | 50 } |
| 45 | 51 |
| 52 // Takes ownership of |loaded_offline_page_info|. |
| 53 void SetLoadedOfflinePageInfo( |
| 54 std::unique_ptr<offline_pages::LoadedOfflinePageInfo> |
| 55 loaded_offline_page_info); |
| 56 |
| 57 offline_pages::LoadedOfflinePageInfo* GetLoadedOfflinePageInfo() const { |
| 58 return loaded_offline_page_info_.get(); |
| 59 } |
| 60 |
| 46 static ChromeNavigationData* GetDataAndCreateIfNecessary( | 61 static ChromeNavigationData* GetDataAndCreateIfNecessary( |
| 47 net::URLRequest* request); | 62 net::URLRequest* request); |
| 48 | 63 |
| 64 static ChromeNavigationData* GetForNavigationHandle( |
| 65 content::NavigationHandle* navigation_handle); |
| 66 |
| 49 private: | 67 private: |
| 50 // Manages the lifetime of optional DataReductionProxy information. | 68 // Manages the lifetime of optional DataReductionProxy information. |
| 51 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> | 69 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> |
| 52 data_reduction_proxy_data_; | 70 data_reduction_proxy_data_; |
| 53 | 71 |
| 72 // Manages the lifetime of optional LoadedOfflinePageInfo information. |
| 73 std::unique_ptr<offline_pages::LoadedOfflinePageInfo> |
| 74 loaded_offline_page_info_; |
| 75 |
| 54 DISALLOW_COPY_AND_ASSIGN(ChromeNavigationData); | 76 DISALLOW_COPY_AND_ASSIGN(ChromeNavigationData); |
| 55 }; | 77 }; |
| 56 | 78 |
| 57 #endif // CHROME_BROWSER_LOADER_CHROME_NAVIGATION_DATA_H_ | 79 #endif // CHROME_BROWSER_LOADER_CHROME_NAVIGATION_DATA_H_ |
| OLD | NEW |