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

Side by Side Diff: content/public/test/test_download_request_handler.h

Issue 2913673002: Replace deprecated base::NonThreadSafe in content/public/test in favor of SequenceChecker. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | content/public/test/test_download_request_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_PUBLIC_TEST_TEST_DOWNLOAD_REQUEST_HANDLER_H_ 5 #ifndef CONTENT_PUBLIC_TEST_TEST_DOWNLOAD_REQUEST_HANDLER_H_
6 #define CONTENT_PUBLIC_TEST_TEST_DOWNLOAD_REQUEST_HANDLER_H_ 6 #define CONTENT_PUBLIC_TEST_TEST_DOWNLOAD_REQUEST_HANDLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <queue> 11 #include <queue>
12 12
13 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
14 #include "base/files/file.h" 14 #include "base/files/file.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/threading/non_thread_safe.h" 17 #include "base/sequence_checker.h"
18 #include "net/base/completion_callback.h" 18 #include "net/base/completion_callback.h"
19 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
20 #include "net/http/http_byte_range.h" 20 #include "net/http/http_byte_range.h"
21 #include "net/http/http_response_headers.h" 21 #include "net/http/http_response_headers.h"
22 #include "net/http/http_util.h" 22 #include "net/http/http_util.h"
23 #include "net/url_request/url_request_job.h" 23 #include "net/url_request/url_request_job.h"
24 #include "url/gurl.h" 24 #include "url/gurl.h"
25 25
26 namespace content { 26 namespace content {
27 27
(...skipping 27 matching lines...) Expand all
55 // 55 //
56 // // Inject an error at offset 100. 56 // // Inject an error at offset 100.
57 // parameters.injected_errors.push(TestDownloadRequestHandler::InjectedError( 57 // parameters.injected_errors.push(TestDownloadRequestHandler::InjectedError(
58 // 100, net::ERR_CONNECTION_RESET)); 58 // 100, net::ERR_CONNECTION_RESET));
59 // 59 //
60 // // Start serving. 60 // // Start serving.
61 // request_handler.StartServing(parameters); 61 // request_handler.StartServing(parameters);
62 // 62 //
63 // At this point, you can initiate a URLRequest for request_handler.url(). The 63 // At this point, you can initiate a URLRequest for request_handler.url(). The
64 // request will fail when offset 100 is reached with the error specified above. 64 // request will fail when offset 100 is reached with the error specified above.
65 class TestDownloadRequestHandler : public base::NonThreadSafe { 65 class TestDownloadRequestHandler {
66 public: 66 public:
67 // OnStartHandler can be used to intercept the Start() event of a new 67 // OnStartHandler can be used to intercept the Start() event of a new
68 // URLRequest. Set it as the |on_start_handler| member of Parameters below. 68 // URLRequest. Set it as the |on_start_handler| member of Parameters below.
69 // 69 //
70 // The callback is invoked on the thread on which TestDownloadRequestHandler 70 // The callback is invoked on the thread on which TestDownloadRequestHandler
71 // was created. Once the callback has a response ready, it can invoke the 71 // was created. Once the callback has a response ready, it can invoke the
72 // OnStartResponseCallback object. The latter can be invoked on any thread and 72 // OnStartResponseCallback object. The latter can be invoked on any thread and
73 // will post back to the IO thread to continue with processing the Start() 73 // will post back to the IO thread to continue with processing the Start()
74 // event. 74 // event.
75 // 75 //
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // Note: Don't use this function to generate a cryptographically secure 312 // Note: Don't use this function to generate a cryptographically secure
313 // pseudo-random sequence. 313 // pseudo-random sequence.
314 static void GetPatternBytes(int seed, int64_t offset, int length, char* data); 314 static void GetPatternBytes(int seed, int64_t offset, int length, char* data);
315 315
316 private: 316 private:
317 class Interceptor; 317 class Interceptor;
318 class PartialResponseJob; 318 class PartialResponseJob;
319 319
320 GURL url_; 320 GURL url_;
321 base::WeakPtr<Interceptor> interceptor_; 321 base::WeakPtr<Interceptor> interceptor_;
322
323 SEQUENCE_CHECKER(sequence_checker_);
324
322 DISALLOW_COPY_AND_ASSIGN(TestDownloadRequestHandler); 325 DISALLOW_COPY_AND_ASSIGN(TestDownloadRequestHandler);
323 }; 326 };
324 327
325 } // namespace content 328 } // namespace content
326 329
327 #endif // CONTENT_PUBLIC_TEST_TEST_DOWNLOAD_REQUEST_HANDLER_H_ 330 #endif // CONTENT_PUBLIC_TEST_TEST_DOWNLOAD_REQUEST_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | content/public/test/test_download_request_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698