OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/storage_partition_impl_map.h" | 5 #include "content/browser/storage_partition_impl_map.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "content/browser/webui/url_data_manager_backend.h" | 28 #include "content/browser/webui/url_data_manager_backend.h" |
29 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/content_browser_client.h" | 31 #include "content/public/browser/content_browser_client.h" |
32 #include "content/public/browser/storage_partition.h" | 32 #include "content/public/browser/storage_partition.h" |
33 #include "content/public/common/content_constants.h" | 33 #include "content/public/common/content_constants.h" |
34 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
35 #include "crypto/sha2.h" | 35 #include "crypto/sha2.h" |
36 #include "net/url_request/url_request_context.h" | 36 #include "net/url_request/url_request_context.h" |
37 #include "net/url_request/url_request_context_getter.h" | 37 #include "net/url_request/url_request_context_getter.h" |
38 #include "webkit/browser/blob/blob_storage_context.h" | 38 #include "storage/browser/blob/blob_storage_context.h" |
39 #include "webkit/browser/blob/blob_url_request_job_factory.h" | 39 #include "storage/browser/blob/blob_url_request_job_factory.h" |
40 #include "webkit/browser/fileapi/file_system_url_request_job_factory.h" | 40 #include "storage/browser/fileapi/file_system_url_request_job_factory.h" |
41 #include "webkit/common/blob/blob_data.h" | 41 #include "storage/common/blob/blob_data.h" |
42 | 42 |
43 using fileapi::FileSystemContext; | 43 using storage::FileSystemContext; |
44 using webkit_blob::BlobStorageContext; | 44 using storage::BlobStorageContext; |
45 | 45 |
46 namespace content { | 46 namespace content { |
47 | 47 |
48 namespace { | 48 namespace { |
49 | 49 |
50 // A derivative that knows about Streams too. | 50 // A derivative that knows about Streams too. |
51 class BlobProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { | 51 class BlobProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { |
52 public: | 52 public: |
53 BlobProtocolHandler(ChromeBlobStorageContext* blob_storage_context, | 53 BlobProtocolHandler(ChromeBlobStorageContext* blob_storage_context, |
54 StreamContext* stream_context, | 54 StreamContext* stream_context, |
55 fileapi::FileSystemContext* file_system_context) | 55 storage::FileSystemContext* file_system_context) |
56 : blob_storage_context_(blob_storage_context), | 56 : blob_storage_context_(blob_storage_context), |
57 stream_context_(stream_context), | 57 stream_context_(stream_context), |
58 file_system_context_(file_system_context) { | 58 file_system_context_(file_system_context) {} |
59 } | |
60 | 59 |
61 virtual ~BlobProtocolHandler() { | 60 virtual ~BlobProtocolHandler() { |
62 } | 61 } |
63 | 62 |
64 virtual net::URLRequestJob* MaybeCreateJob( | 63 virtual net::URLRequestJob* MaybeCreateJob( |
65 net::URLRequest* request, | 64 net::URLRequest* request, |
66 net::NetworkDelegate* network_delegate) const OVERRIDE { | 65 net::NetworkDelegate* network_delegate) const OVERRIDE { |
67 scoped_refptr<Stream> stream = | 66 scoped_refptr<Stream> stream = |
68 stream_context_->registry()->GetStream(request->url()); | 67 stream_context_->registry()->GetStream(request->url()); |
69 if (stream.get()) | 68 if (stream.get()) |
70 return new StreamURLRequestJob(request, network_delegate, stream); | 69 return new StreamURLRequestJob(request, network_delegate, stream); |
71 | 70 |
72 if (!blob_protocol_handler_) { | 71 if (!blob_protocol_handler_) { |
73 // Construction is deferred because 'this' is constructed on | 72 // Construction is deferred because 'this' is constructed on |
74 // the main thread but we want blob_protocol_handler_ constructed | 73 // the main thread but we want blob_protocol_handler_ constructed |
75 // on the IO thread. | 74 // on the IO thread. |
76 blob_protocol_handler_.reset( | 75 blob_protocol_handler_.reset(new storage::BlobProtocolHandler( |
77 new webkit_blob::BlobProtocolHandler( | 76 blob_storage_context_->context(), |
78 blob_storage_context_->context(), | 77 file_system_context_, |
79 file_system_context_, | 78 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) |
80 BrowserThread::GetMessageLoopProxyForThread( | 79 .get())); |
81 BrowserThread::FILE).get())); | |
82 } | 80 } |
83 return blob_protocol_handler_->MaybeCreateJob(request, network_delegate); | 81 return blob_protocol_handler_->MaybeCreateJob(request, network_delegate); |
84 } | 82 } |
85 | 83 |
86 private: | 84 private: |
87 const scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; | 85 const scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; |
88 const scoped_refptr<StreamContext> stream_context_; | 86 const scoped_refptr<StreamContext> stream_context_; |
89 const scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 87 const scoped_refptr<storage::FileSystemContext> file_system_context_; |
90 mutable scoped_ptr<webkit_blob::BlobProtocolHandler> blob_protocol_handler_; | 88 mutable scoped_ptr<storage::BlobProtocolHandler> blob_protocol_handler_; |
91 DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler); | 89 DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler); |
92 }; | 90 }; |
93 | 91 |
94 // These constants are used to create the directory structure under the profile | 92 // These constants are used to create the directory structure under the profile |
95 // where renderers with a non-default storage partition keep their persistent | 93 // where renderers with a non-default storage partition keep their persistent |
96 // state. This will contain a set of directories that partially mirror the | 94 // state. This will contain a set of directories that partially mirror the |
97 // directory structure of BrowserContext::GetPath(). | 95 // directory structure of BrowserContext::GetPath(). |
98 // | 96 // |
99 // The kStoragePartitionDirname contains an extensions directory which is | 97 // The kStoragePartitionDirname contains an extensions directory which is |
100 // further partitioned by extension id, followed by another level of directories | 98 // further partitioned by extension id, followed by another level of directories |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 | 589 |
592 // We do not call InitializeURLRequestContext() for media contexts because, | 590 // We do not call InitializeURLRequestContext() for media contexts because, |
593 // other than the HTTP cache, the media contexts share the same backing | 591 // other than the HTTP cache, the media contexts share the same backing |
594 // objects as their associated "normal" request context. Thus, the previous | 592 // objects as their associated "normal" request context. Thus, the previous |
595 // call serves to initialize the media request context for this storage | 593 // call serves to initialize the media request context for this storage |
596 // partition as well. | 594 // partition as well. |
597 } | 595 } |
598 } | 596 } |
599 | 597 |
600 } // namespace content | 598 } // namespace content |
OLD | NEW |