Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / browser / service_worker / service_worker_context_request_handler.h
1 // Copyright 2014 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_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_REQUEST_HANDLER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_REQUEST_HANDLER_H_
7
8 #include "content/browser/service_worker/service_worker_request_handler.h"
9
10 namespace content {
11
12 class ServiceWorkerVersion;
13
14 // A request handler derivative used to handle requests from
15 // service workers.
16 class CONTENT_EXPORT ServiceWorkerContextRequestHandler
17     : public ServiceWorkerRequestHandler {
18  public:
19   ServiceWorkerContextRequestHandler(
20       base::WeakPtr<ServiceWorkerContextCore> context,
21       base::WeakPtr<ServiceWorkerProviderHost> provider_host,
22       base::WeakPtr<storage::BlobStorageContext> blob_storage_context,
23       ResourceType resource_type);
24   ~ServiceWorkerContextRequestHandler() override;
25
26   // Called via custom URLRequestJobFactory.
27   net::URLRequestJob* MaybeCreateJob(
28       net::URLRequest* request,
29       net::NetworkDelegate* network_delegate,
30       ResourceContext* resource_context) override;
31
32   void GetExtraResponseInfo(
33       bool* was_fetched_via_service_worker,
34       bool* was_fallback_required_by_service_worker,
35       GURL* original_url_via_service_worker,
36       blink::WebServiceWorkerResponseType* response_type_via_service_worker,
37       base::TimeTicks* fetch_start_time,
38       base::TimeTicks* fetch_ready_time,
39       base::TimeTicks* fetch_end_time) const override;
40
41  private:
42   bool ShouldAddToScriptCache(const GURL& url);
43   bool ShouldReadFromScriptCache(const GURL& url, int64* response_id_out);
44
45   scoped_refptr<ServiceWorkerVersion> version_;
46
47   DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextRequestHandler);
48 };
49
50 }  // namespace content
51
52 #endif  // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_REQUEST_HANDLER_H_