Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: content/browser/loader/mojo_async_resource_handler.h

Issue 2526983002: Refactor ResourceHandler API. (Closed)
Patch Set: Response to comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 18 matching lines...) Expand all
29 namespace tracked_objects { 29 namespace tracked_objects {
30 class Location; 30 class Location;
31 } 31 }
32 32
33 namespace net { 33 namespace net {
34 class IOBufferWithSize; 34 class IOBufferWithSize;
35 class URLRequest; 35 class URLRequest;
36 } 36 }
37 37
38 namespace content { 38 namespace content {
39 class ResourceController;
39 class ResourceDispatcherHostImpl; 40 class ResourceDispatcherHostImpl;
40 struct ResourceResponse; 41 struct ResourceResponse;
41 42
42 // Used to complete an asynchronous resource request in response to resource 43 // Used to complete an asynchronous resource request in response to resource
43 // load events from the resource dispatcher host. This class is used only 44 // load events from the resource dispatcher host. This class is used only
44 // when LoadingWithMojo runtime flag is enabled. 45 // when LoadingWithMojo runtime flag is enabled.
45 // 46 //
46 // TODO(yhirano): Add histograms. 47 // TODO(yhirano): Add histograms.
47 // TODO(yhirano): Send cached metadata. 48 // TODO(yhirano): Send cached metadata.
48 // 49 //
49 // This class can be inherited only for tests. 50 // This class can be inherited only for tests.
50 class CONTENT_EXPORT MojoAsyncResourceHandler 51 class CONTENT_EXPORT MojoAsyncResourceHandler
51 : public ResourceHandler, 52 : public ResourceHandler,
52 public NON_EXPORTED_BASE(mojom::URLLoader) { 53 public NON_EXPORTED_BASE(mojom::URLLoader) {
53 public: 54 public:
54 MojoAsyncResourceHandler( 55 MojoAsyncResourceHandler(
55 net::URLRequest* request, 56 net::URLRequest* request,
56 ResourceDispatcherHostImpl* rdh, 57 ResourceDispatcherHostImpl* rdh,
57 mojom::URLLoaderAssociatedRequest mojo_request, 58 mojom::URLLoaderAssociatedRequest mojo_request,
58 mojom::URLLoaderClientAssociatedPtr url_loader_client, 59 mojom::URLLoaderClientAssociatedPtr url_loader_client,
59 ResourceType resource_type); 60 ResourceType resource_type);
60 ~MojoAsyncResourceHandler() override; 61 ~MojoAsyncResourceHandler() override;
61 62
62 // ResourceHandler implementation: 63 // ResourceHandler implementation:
63 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, 64 void OnRequestRedirected(
64 ResourceResponse* response, 65 const net::RedirectInfo& redirect_info,
65 bool* defer) override; 66 ResourceResponse* response,
66 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; 67 std::unique_ptr<ResourceController> controller) override;
67 bool OnWillStart(const GURL& url, bool* defer) override; 68 void OnResponseStarted(
69 ResourceResponse* response,
70 std::unique_ptr<ResourceController> controller) override;
71 void OnWillStart(const GURL& url,
72 std::unique_ptr<ResourceController> controller) override;
68 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, 73 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf,
69 int* buf_size, 74 int* buf_size,
70 int min_size) override; 75 int min_size) override;
71 bool OnReadCompleted(int bytes_read, bool* defer) override; 76 void OnReadCompleted(int bytes_read,
72 void OnResponseCompleted(const net::URLRequestStatus& status, 77 std::unique_ptr<ResourceController> controller) override;
73 bool* defer) override; 78 void OnResponseCompleted(
79 const net::URLRequestStatus& status,
80 std::unique_ptr<ResourceController> controller) override;
74 void OnDataDownloaded(int bytes_downloaded) override; 81 void OnDataDownloaded(int bytes_downloaded) override;
75 82
76 // mojom::URLLoader implementation: 83 // mojom::URLLoader implementation:
77 void FollowRedirect() override; 84 void FollowRedirect() override;
78 void SetPriority(net::RequestPriority priority, 85 void SetPriority(net::RequestPriority priority,
79 int32_t intra_priority_value) override; 86 int32_t intra_priority_value) override;
80 87
81 void OnWritableForTesting(); 88 void OnWritableForTesting();
82 static void SetAllocationSizeForTesting(size_t size); 89 static void SetAllocationSizeForTesting(size_t size);
83 static constexpr size_t kDefaultAllocationSize = 512 * 1024; 90 static constexpr size_t kDefaultAllocationSize = 512 * 1024;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 149
143 std::unique_ptr<UploadProgressTracker> upload_progress_tracker_; 150 std::unique_ptr<UploadProgressTracker> upload_progress_tracker_;
144 151
145 base::WeakPtrFactory<MojoAsyncResourceHandler> weak_factory_; 152 base::WeakPtrFactory<MojoAsyncResourceHandler> weak_factory_;
146 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler); 153 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandler);
147 }; 154 };
148 155
149 } // namespace content 156 } // namespace content
150 157
151 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_ 158 #endif // CONTENT_BROWSER_LOADER_MOJO_ASYNC_RESOURCE_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/loader/mock_resource_loader.cc ('k') | content/browser/loader/mojo_async_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698