| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "content/browser/loader/resource_handler.h" | 16 #include "content/browser/loader/resource_handler.h" |
| 17 #include "content/browser/loader/upload_progress_tracker.h" | 17 #include "content/browser/loader/upload_progress_tracker.h" |
| 18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "content/common/url_loader.mojom.h" | 19 #include "content/common/url_loader.mojom.h" |
| 20 #include "content/public/common/resource_type.h" | 20 #include "content/public/common/resource_type.h" |
| 21 #include "mojo/public/cpp/bindings/associated_binding.h" | 21 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 22 #include "mojo/public/cpp/system/data_pipe.h" | 22 #include "mojo/public/cpp/system/data_pipe.h" |
| 23 #include "mojo/public/cpp/system/watcher.h" | 23 #include "mojo/public/cpp/system/watcher.h" |
| 24 #include "net/base/io_buffer.h" | 24 #include "net/base/io_buffer.h" |
| 25 #include "net/base/request_priority.h" |
| 25 | 26 |
| 26 class GURL; | 27 class GURL; |
| 27 | 28 |
| 28 namespace tracked_objects { | 29 namespace tracked_objects { |
| 29 class Location; | 30 class Location; |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace net { | 33 namespace net { |
| 33 class IOBufferWithSize; | 34 class IOBufferWithSize; |
| 34 class URLRequest; | 35 class URLRequest; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 68 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| 68 int* buf_size, | 69 int* buf_size, |
| 69 int min_size) override; | 70 int min_size) override; |
| 70 bool OnReadCompleted(int bytes_read, bool* defer) override; | 71 bool OnReadCompleted(int bytes_read, bool* defer) override; |
| 71 void OnResponseCompleted(const net::URLRequestStatus& status, | 72 void OnResponseCompleted(const net::URLRequestStatus& status, |
| 72 bool* defer) override; | 73 bool* defer) override; |
| 73 void OnDataDownloaded(int bytes_downloaded) override; | 74 void OnDataDownloaded(int bytes_downloaded) override; |
| 74 | 75 |
| 75 // mojom::URLLoader implementation: | 76 // mojom::URLLoader implementation: |
| 76 void FollowRedirect() override; | 77 void FollowRedirect() override; |
| 78 void SetPriority(net::RequestPriority priority, |
| 79 int32_t intra_priority_value) override; |
| 77 | 80 |
| 78 void OnWritableForTesting(); | 81 void OnWritableForTesting(); |
| 79 static void SetAllocationSizeForTesting(size_t size); | 82 static void SetAllocationSizeForTesting(size_t size); |
| 80 static constexpr size_t kDefaultAllocationSize = 512 * 1024; | 83 static constexpr size_t kDefaultAllocationSize = 512 * 1024; |
| 81 | 84 |
| 82 protected: | 85 protected: |
| 83 // These functions can be overriden only for tests. | 86 // These functions can be overriden only for tests. |
| 84 virtual MojoResult BeginWrite(void** data, uint32_t* available); | 87 virtual MojoResult BeginWrite(void** data, uint32_t* available); |
| 85 virtual MojoResult EndWrite(uint32_t written); | 88 virtual MojoResult EndWrite(uint32_t written); |
| 86 virtual net::IOBufferWithSize* GetResponseMetadata(net::URLRequest* request); | 89 virtual net::IOBufferWithSize* GetResponseMetadata(net::URLRequest* request); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 142 |
| 140 std::unique_ptr<UploadProgressTracker> upload_progress_tracker_; | 143 std::unique_ptr<UploadProgressTracker> upload_progress_tracker_; |
| 141 | 144 |
| 142 base::WeakPtrFactory<MojoAsyncResourceHandler> weak_factory_; | 145 base::WeakPtrFactory<MojoAsyncResourceHandler> weak_factory_; |
| 143 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); | 146 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); |
| 144 }; | 147 }; |
| 145 | 148 |
| 146 } // namespace content | 149 } // namespace content |
| 147 | 150 |
| 148 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ | 151 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ |
| OLD | NEW |