OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_LOADER_OFFLINE_POLICY |
| 6 #define CONTENT_BROWSER_LOADER_OFFLINE_POLICY |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "content/common/content_export.h" |
| 12 |
| 13 struct ResourceHostMsg_Request; |
| 14 |
| 15 namespace net { |
| 16 class HttpResponseInfo; |
| 17 class URLRequest; |
| 18 } |
| 19 |
| 20 namespace content { |
| 21 |
| 22 // This class controls under what conditions resources will be fetched |
| 23 // from cache even if stale rather than from the network. For example, |
| 24 // one policy would be that if requests for a particular route (e.g. "tab") |
| 25 // is unable to reach the server, other requests made with the same route |
| 26 // can be loaded from cache without first requiring a network timeout. |
| 27 // |
| 28 // There is a single OfflinePolicy object per user navigation unit |
| 29 // (generally a tab). |
| 30 class CONTENT_EXPORT OfflinePolicy { |
| 31 public: |
| 32 OfflinePolicy(); |
| 33 ~OfflinePolicy(); |
| 34 |
| 35 // Return any additional load flags to be ORed for a request from |
| 36 // this route with the given |resource_type|. |reset_state| indicates |
| 37 // that this request should reinitialized the internal state for this |
| 38 // policy object (e.g. in the case of a main frame load). |
| 39 int GetAdditionalLoadFlags(int current_flags, bool reset_state); |
| 40 |
| 41 // Incorporate online/offline information from a completed request. |
| 42 void UpdateStateForCompletedRequest( |
| 43 const net::HttpResponseInfo& response_info); |
| 44 |
| 45 private: |
| 46 enum State { INIT, ONLINE, OFFLINE }; |
| 47 |
| 48 bool enabled_; |
| 49 State state_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(OfflinePolicy); |
| 52 }; |
| 53 |
| 54 } // namespace content |
| 55 |
| 56 #endif // CONTENT_BROWSER_LOADER_OFFLINE_POLICY |
OLD | NEW |