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

Side by Side Diff: net/spdy/spdy_test_util_common.h

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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 | « net/spdy/spdy_stream.h ('k') | net/spdy/spdy_test_util_common.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ 5 #ifndef NET_SPDY_SPDY_TEST_UTIL_COMMON_H_
6 #define NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ 6 #define NET_SPDY_SPDY_TEST_UTIL_COMMON_H_
7 7
8 #include <stddef.h>
9 #include <stdint.h>
10
8 #include <string> 11 #include <string>
9 #include <vector> 12 #include <vector>
10 13
14 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
13 #include "crypto/ec_private_key.h" 17 #include "crypto/ec_private_key.h"
14 #include "crypto/ec_signature_creator.h" 18 #include "crypto/ec_signature_creator.h"
15 #include "net/base/completion_callback.h" 19 #include "net/base/completion_callback.h"
16 #include "net/base/request_priority.h" 20 #include "net/base/request_priority.h"
17 #include "net/base/test_completion_callback.h" 21 #include "net/base/test_completion_callback.h"
18 #include "net/cert/cert_verifier.h" 22 #include "net/cert/cert_verifier.h"
19 #include "net/dns/mock_host_resolver.h" 23 #include "net/dns/mock_host_resolver.h"
20 #include "net/http/http_auth_handler_factory.h" 24 #include "net/http/http_auth_handler_factory.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // This struct holds information used to construct spdy control and data frames. 126 // This struct holds information used to construct spdy control and data frames.
123 struct SpdyHeaderInfo { 127 struct SpdyHeaderInfo {
124 SpdyFrameType kind; 128 SpdyFrameType kind;
125 SpdyStreamId id; 129 SpdyStreamId id;
126 SpdyStreamId assoc_id; 130 SpdyStreamId assoc_id;
127 SpdyPriority priority; 131 SpdyPriority priority;
128 SpdyControlFlags control_flags; 132 SpdyControlFlags control_flags;
129 bool compressed; 133 bool compressed;
130 SpdyRstStreamStatus status; 134 SpdyRstStreamStatus status;
131 const char* data; 135 const char* data;
132 uint32 data_length; 136 uint32_t data_length;
133 SpdyDataFlags data_flags; 137 SpdyDataFlags data_flags;
134 }; 138 };
135 139
136 // An ECSignatureCreator that returns deterministic signatures. 140 // An ECSignatureCreator that returns deterministic signatures.
137 class MockECSignatureCreator : public crypto::ECSignatureCreator { 141 class MockECSignatureCreator : public crypto::ECSignatureCreator {
138 public: 142 public:
139 explicit MockECSignatureCreator(crypto::ECPrivateKey* key); 143 explicit MockECSignatureCreator(crypto::ECPrivateKey* key);
140 144
141 // crypto::ECSignatureCreator 145 // crypto::ECSignatureCreator
142 bool Sign(const uint8* data, 146 bool Sign(const uint8_t* data,
143 int data_len, 147 int data_len,
144 std::vector<uint8>* signature) override; 148 std::vector<uint8_t>* signature) override;
145 bool DecodeSignature(const std::vector<uint8>& signature, 149 bool DecodeSignature(const std::vector<uint8_t>& signature,
146 std::vector<uint8>* out_raw_sig) override; 150 std::vector<uint8_t>* out_raw_sig) override;
147 151
148 private: 152 private:
149 crypto::ECPrivateKey* key_; 153 crypto::ECPrivateKey* key_;
150 154
151 DISALLOW_COPY_AND_ASSIGN(MockECSignatureCreator); 155 DISALLOW_COPY_AND_ASSIGN(MockECSignatureCreator);
152 }; 156 };
153 157
154 // An ECSignatureCreatorFactory creates MockECSignatureCreator. 158 // An ECSignatureCreatorFactory creates MockECSignatureCreator.
155 class MockECSignatureCreatorFactory : public crypto::ECSignatureCreatorFactory { 159 class MockECSignatureCreatorFactory : public crypto::ECSignatureCreatorFactory {
156 public: 160 public:
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 // Add the appropriate headers to put |url| into |block|. 288 // Add the appropriate headers to put |url| into |block|.
285 void AddUrlToHeaderBlock(base::StringPiece url, 289 void AddUrlToHeaderBlock(base::StringPiece url,
286 SpdyHeaderBlock* headers) const; 290 SpdyHeaderBlock* headers) const;
287 291
288 scoped_ptr<SpdyHeaderBlock> ConstructGetHeaderBlock( 292 scoped_ptr<SpdyHeaderBlock> ConstructGetHeaderBlock(
289 base::StringPiece url) const; 293 base::StringPiece url) const;
290 scoped_ptr<SpdyHeaderBlock> ConstructGetHeaderBlockForProxy( 294 scoped_ptr<SpdyHeaderBlock> ConstructGetHeaderBlockForProxy(
291 base::StringPiece url) const; 295 base::StringPiece url) const;
292 scoped_ptr<SpdyHeaderBlock> ConstructHeadHeaderBlock( 296 scoped_ptr<SpdyHeaderBlock> ConstructHeadHeaderBlock(
293 base::StringPiece url, 297 base::StringPiece url,
294 int64 content_length) const; 298 int64_t content_length) const;
295 scoped_ptr<SpdyHeaderBlock> ConstructPostHeaderBlock( 299 scoped_ptr<SpdyHeaderBlock> ConstructPostHeaderBlock(
296 base::StringPiece url, 300 base::StringPiece url,
297 int64 content_length) const; 301 int64_t content_length) const;
298 scoped_ptr<SpdyHeaderBlock> ConstructPutHeaderBlock( 302 scoped_ptr<SpdyHeaderBlock> ConstructPutHeaderBlock(
299 base::StringPiece url, 303 base::StringPiece url,
300 int64 content_length) const; 304 int64_t content_length) const;
301 305
302 // Construct a SPDY frame. If it is a SYN_STREAM or SYN_REPLY frame (as 306 // Construct a SPDY frame. If it is a SYN_STREAM or SYN_REPLY frame (as
303 // specified in header_info.kind), the provided headers are included in the 307 // specified in header_info.kind), the provided headers are included in the
304 // frame. 308 // frame.
305 SpdyFrame* ConstructSpdyFrame( 309 SpdyFrame* ConstructSpdyFrame(
306 const SpdyHeaderInfo& header_info, 310 const SpdyHeaderInfo& header_info,
307 scoped_ptr<SpdyHeaderBlock> headers) const; 311 scoped_ptr<SpdyHeaderBlock> headers) const;
308 312
309 // Construct a SPDY frame. If it is a SYN_STREAM or SYN_REPLY frame (as 313 // Construct a SPDY frame. If it is a SYN_STREAM or SYN_REPLY frame (as
310 // specified in header_info.kind), the headers provided in extra_headers and 314 // specified in header_info.kind), the headers provided in extra_headers and
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 // |settings| are the settings to set. 355 // |settings| are the settings to set.
352 // Returns the constructed frame. The caller takes ownership of the frame. 356 // Returns the constructed frame. The caller takes ownership of the frame.
353 SpdyFrame* ConstructSpdySettings(const SettingsMap& settings) const; 357 SpdyFrame* ConstructSpdySettings(const SettingsMap& settings) const;
354 358
355 // Constructs an expected SPDY SETTINGS acknowledgement frame, if the protocol 359 // Constructs an expected SPDY SETTINGS acknowledgement frame, if the protocol
356 // version is SPDY4 or higher, or an empty placeholder frame otherwise. 360 // version is SPDY4 or higher, or an empty placeholder frame otherwise.
357 SpdyFrame* ConstructSpdySettingsAck() const; 361 SpdyFrame* ConstructSpdySettingsAck() const;
358 362
359 // Construct a SPDY PING frame. 363 // Construct a SPDY PING frame.
360 // Returns the constructed frame. The caller takes ownership of the frame. 364 // Returns the constructed frame. The caller takes ownership of the frame.
361 SpdyFrame* ConstructSpdyPing(uint32 ping_id, bool is_ack) const; 365 SpdyFrame* ConstructSpdyPing(uint32_t ping_id, bool is_ack) const;
362 366
363 // Construct a SPDY GOAWAY frame with last_good_stream_id = 0. 367 // Construct a SPDY GOAWAY frame with last_good_stream_id = 0.
364 // Returns the constructed frame. The caller takes ownership of the frame. 368 // Returns the constructed frame. The caller takes ownership of the frame.
365 SpdyFrame* ConstructSpdyGoAway() const; 369 SpdyFrame* ConstructSpdyGoAway() const;
366 370
367 // Construct a SPDY GOAWAY frame with the specified last_good_stream_id. 371 // Construct a SPDY GOAWAY frame with the specified last_good_stream_id.
368 // Returns the constructed frame. The caller takes ownership of the frame. 372 // Returns the constructed frame. The caller takes ownership of the frame.
369 SpdyFrame* ConstructSpdyGoAway(SpdyStreamId last_good_stream_id) const; 373 SpdyFrame* ConstructSpdyGoAway(SpdyStreamId last_good_stream_id) const;
370 374
371 // Construct a SPDY GOAWAY frame with the specified last_good_stream_id, 375 // Construct a SPDY GOAWAY frame with the specified last_good_stream_id,
372 // status, and description. Returns the constructed frame. The caller takes 376 // status, and description. Returns the constructed frame. The caller takes
373 // ownership of the frame. 377 // ownership of the frame.
374 SpdyFrame* ConstructSpdyGoAway(SpdyStreamId last_good_stream_id, 378 SpdyFrame* ConstructSpdyGoAway(SpdyStreamId last_good_stream_id,
375 SpdyGoAwayStatus status, 379 SpdyGoAwayStatus status,
376 const std::string& desc) const; 380 const std::string& desc) const;
377 381
378 // Construct a SPDY WINDOW_UPDATE frame. 382 // Construct a SPDY WINDOW_UPDATE frame.
379 // Returns the constructed frame. The caller takes ownership of the frame. 383 // Returns the constructed frame. The caller takes ownership of the frame.
380 SpdyFrame* ConstructSpdyWindowUpdate( 384 SpdyFrame* ConstructSpdyWindowUpdate(SpdyStreamId stream_id,
381 SpdyStreamId stream_id, 385 uint32_t delta_window_size) const;
382 uint32 delta_window_size) const;
383 386
384 // Construct a SPDY RST_STREAM frame. 387 // Construct a SPDY RST_STREAM frame.
385 // Returns the constructed frame. The caller takes ownership of the frame. 388 // Returns the constructed frame. The caller takes ownership of the frame.
386 SpdyFrame* ConstructSpdyRstStream(SpdyStreamId stream_id, 389 SpdyFrame* ConstructSpdyRstStream(SpdyStreamId stream_id,
387 SpdyRstStreamStatus status) const; 390 SpdyRstStreamStatus status) const;
388 391
389 // Constructs a standard SPDY GET SYN frame, optionally compressed 392 // Constructs a standard SPDY GET SYN frame, optionally compressed
390 // for |url|. 393 // for |url|.
391 // |extra_headers| are the extra header-value pairs, which typically 394 // |extra_headers| are the extra header-value pairs, which typically
392 // will vary the most between calls. 395 // will vary the most between calls.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 const char* const* const extra_headers, 486 const char* const* const extra_headers,
484 int extra_header_count, 487 int extra_header_count,
485 int stream_id); 488 int stream_id);
486 489
487 // Constructs a standard SPDY POST SYN frame. 490 // Constructs a standard SPDY POST SYN frame.
488 // |extra_headers| are the extra header-value pairs, which typically 491 // |extra_headers| are the extra header-value pairs, which typically
489 // will vary the most between calls. 492 // will vary the most between calls.
490 // Returns a SpdyFrame. 493 // Returns a SpdyFrame.
491 SpdyFrame* ConstructSpdyPost(const char* url, 494 SpdyFrame* ConstructSpdyPost(const char* url,
492 SpdyStreamId stream_id, 495 SpdyStreamId stream_id,
493 int64 content_length, 496 int64_t content_length,
494 RequestPriority priority, 497 RequestPriority priority,
495 const char* const extra_headers[], 498 const char* const extra_headers[],
496 int extra_header_count); 499 int extra_header_count);
497 500
498 // Constructs a chunked transfer SPDY POST SYN frame. 501 // Constructs a chunked transfer SPDY POST SYN frame.
499 // |extra_headers| are the extra header-value pairs, which typically 502 // |extra_headers| are the extra header-value pairs, which typically
500 // will vary the most between calls. 503 // will vary the most between calls.
501 // Returns a SpdyFrame. 504 // Returns a SpdyFrame.
502 SpdyFrame* ConstructChunkedSpdyPost(const char* const extra_headers[], 505 SpdyFrame* ConstructChunkedSpdyPost(const char* const extra_headers[],
503 int extra_header_count); 506 int extra_header_count);
504 507
505 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY POST. 508 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY POST.
506 // |extra_headers| are the extra header-value pairs, which typically 509 // |extra_headers| are the extra header-value pairs, which typically
507 // will vary the most between calls. 510 // will vary the most between calls.
508 // Returns a SpdyFrame. 511 // Returns a SpdyFrame.
509 SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[], 512 SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[],
510 int extra_header_count); 513 int extra_header_count);
511 514
512 // Constructs a single SPDY data frame with the contents "hello!" 515 // Constructs a single SPDY data frame with the contents "hello!"
513 SpdyFrame* ConstructSpdyBodyFrame(int stream_id, 516 SpdyFrame* ConstructSpdyBodyFrame(int stream_id,
514 bool fin); 517 bool fin);
515 518
516 // Constructs a single SPDY data frame with the given content. 519 // Constructs a single SPDY data frame with the given content.
517 SpdyFrame* ConstructSpdyBodyFrame(int stream_id, const char* data, 520 SpdyFrame* ConstructSpdyBodyFrame(int stream_id,
518 uint32 len, bool fin); 521 const char* data,
522 uint32_t len,
523 bool fin);
519 524
520 // Constructs a single SPDY data frame with the given content and padding. 525 // Constructs a single SPDY data frame with the given content and padding.
521 SpdyFrame* ConstructSpdyBodyFrame(int stream_id, 526 SpdyFrame* ConstructSpdyBodyFrame(int stream_id,
522 const char* data, 527 const char* data,
523 uint32 len, 528 uint32_t len,
524 bool fin, 529 bool fin,
525 int padding_length); 530 int padding_length);
526 531
527 // Wraps |frame| in the payload of a data frame in stream |stream_id|. 532 // Wraps |frame| in the payload of a data frame in stream |stream_id|.
528 SpdyFrame* ConstructWrappedSpdyFrame(const scoped_ptr<SpdyFrame>& frame, 533 SpdyFrame* ConstructWrappedSpdyFrame(const scoped_ptr<SpdyFrame>& frame,
529 int stream_id); 534 int stream_id);
530 535
531 // Called when necessary (when it will affect stream dependency specification 536 // Called when necessary (when it will affect stream dependency specification
532 // when setting dependencies based on priorioties) to notify the utility 537 // when setting dependencies based on priorioties) to notify the utility
533 // class of stream destruction. 538 // class of stream destruction.
(...skipping 20 matching lines...) Expand all
554 const char* GetSchemeKey() const; 559 const char* GetSchemeKey() const;
555 const char* GetVersionKey() const; 560 const char* GetVersionKey() const;
556 const char* GetPathKey() const; 561 const char* GetPathKey() const;
557 562
558 private: 563 private:
559 // |content_length| may be NULL, in which case the content-length 564 // |content_length| may be NULL, in which case the content-length
560 // header will be omitted. 565 // header will be omitted.
561 scoped_ptr<SpdyHeaderBlock> ConstructHeaderBlock( 566 scoped_ptr<SpdyHeaderBlock> ConstructHeaderBlock(
562 base::StringPiece method, 567 base::StringPiece method,
563 base::StringPiece url, 568 base::StringPiece url,
564 int64* content_length) const; 569 int64_t* content_length) const;
565 570
566 const NextProto protocol_; 571 const NextProto protocol_;
567 const SpdyMajorVersion spdy_version_; 572 const SpdyMajorVersion spdy_version_;
568 GURL default_url_; 573 GURL default_url_;
569 bool dependency_priorities_; 574 bool dependency_priorities_;
570 575
571 // Track a FIFO list of the stream_id of all created requests by priority. 576 // Track a FIFO list of the stream_id of all created requests by priority.
572 std::map<int, std::vector<int>> priority_to_stream_id_list_; 577 std::map<int, std::vector<int>> priority_to_stream_id_list_;
573 }; 578 };
574 579
575 } // namespace net 580 } // namespace net
576 581
577 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ 582 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_stream.h ('k') | net/spdy/spdy_test_util_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698