OLD | NEW |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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 CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_ |
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/sequence_checker.h" |
12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
13 #include "base/threading/non_thread_safe.h" | |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 class NetworkDelegate; | 18 class NetworkDelegate; |
19 class URLRequestJob; | 19 class URLRequestJob; |
20 } | 20 } |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 | 23 |
24 class AppCacheEntry; | 24 class AppCacheEntry; |
25 class AppCacheHost; | 25 class AppCacheHost; |
26 class AppCacheRequest; | 26 class AppCacheRequest; |
27 class AppCacheStorage; | 27 class AppCacheStorage; |
28 class AppCacheURLLoaderJob; | 28 class AppCacheURLLoaderJob; |
29 class URLRequestJob; | 29 class URLRequestJob; |
30 | 30 |
31 // Interface for an AppCache job. This is used to send data stored in the | 31 // Interface for an AppCache job. This is used to send data stored in the |
32 // AppCache to networking consumers. | 32 // AppCache to networking consumers. |
33 // Subclasses implement this interface to wrap custom job objects like | 33 // Subclasses implement this interface to wrap custom job objects like |
34 // URLRequestJob, URLLoaderJob, etc to ensure that these dependencies stay out | 34 // URLRequestJob, URLLoaderJob, etc to ensure that these dependencies stay out |
35 // of the AppCache code. | 35 // of the AppCache code. |
36 class CONTENT_EXPORT AppCacheJob | 36 class CONTENT_EXPORT AppCacheJob : public base::SupportsWeakPtr<AppCacheJob> { |
37 : NON_EXPORTED_BASE(public base::NonThreadSafe), | |
38 public base::SupportsWeakPtr<AppCacheJob> { | |
39 public: | 37 public: |
40 // Callback that will be invoked before the request is restarted. The caller | 38 // Callback that will be invoked before the request is restarted. The caller |
41 // can use this opportunity to grab state from the job to determine how it | 39 // can use this opportunity to grab state from the job to determine how it |
42 // should behave when the request is restarted. | 40 // should behave when the request is restarted. |
43 // TODO(ananta) | 41 // TODO(ananta) |
44 // This applies only to the URLRequestJob at the moment. Look into taking | 42 // This applies only to the URLRequestJob at the moment. Look into taking |
45 // this knowledge out of this class. | 43 // this knowledge out of this class. |
46 using OnPrepareToRestartCallback = base::Closure; | 44 using OnPrepareToRestartCallback = base::Closure; |
47 | 45 |
48 // Factory function to create the AppCacheJob instance for the |request| | 46 // Factory function to create the AppCacheJob instance for the |request| |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // AppCaches loaded via the URLLoader mechanism. | 102 // AppCaches loaded via the URLLoader mechanism. |
105 virtual net::URLRequestJob* AsURLRequestJob(); | 103 virtual net::URLRequestJob* AsURLRequestJob(); |
106 | 104 |
107 // Returns the underlying ApppCacheURLLoaderJob if any. This only applies to | 105 // Returns the underlying ApppCacheURLLoaderJob if any. This only applies to |
108 // AppCaches loaded via the URLRequest mechanism. | 106 // AppCaches loaded via the URLRequest mechanism. |
109 virtual AppCacheURLLoaderJob* AsURLLoaderJob(); | 107 virtual AppCacheURLLoaderJob* AsURLLoaderJob(); |
110 | 108 |
111 protected: | 109 protected: |
112 AppCacheJob(); | 110 AppCacheJob(); |
113 | 111 |
| 112 SEQUENCE_CHECKER(sequence_checker_); |
| 113 |
114 base::WeakPtrFactory<AppCacheJob> weak_factory_; | 114 base::WeakPtrFactory<AppCacheJob> weak_factory_; |
115 | 115 |
116 DISALLOW_COPY_AND_ASSIGN(AppCacheJob); | 116 DISALLOW_COPY_AND_ASSIGN(AppCacheJob); |
117 }; | 117 }; |
118 | 118 |
119 } // namespace content | 119 } // namespace content |
120 | 120 |
121 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_ | 121 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_ |
OLD | NEW |