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.
5 #ifndef CONTENT_BROWSER_LOADER_OFFLINE_POLICY
6 #define CONTENT_BROWSER_LOADER_OFFLINE_POLICY
10 #include "base/basictypes.h"
11 #include "content/common/content_export.h"
13 struct ResourceHostMsg_Request
;
16 class HttpResponseInfo
;
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.
28 // There is a single OfflinePolicy object per user navigation unit
30 class CONTENT_EXPORT OfflinePolicy
{
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
);
41 // Incorporate online/offline information from a successfully started request.
42 void UpdateStateForSuccessfullyStartedRequest(
43 const net::HttpResponseInfo
& response_info
);
46 enum State
{ INIT
, ONLINE
, OFFLINE
};
48 void RecordAndResetStats();
52 int resource_loads_initiated_
;
53 int resource_loads_successfully_started_
;
55 DISALLOW_COPY_AND_ASSIGN(OfflinePolicy
);
58 } // namespace content
60 #endif // CONTENT_BROWSER_LOADER_OFFLINE_POLICY