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

Side by Side Diff: webrtc/base/stream.h

Issue 1345433002: Add RTC_ prefix to contructormagic macros. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Formatting fix. Created 5 years, 3 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 | « webrtc/base/sslidentity.h ('k') | webrtc/base/task_unittest.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 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // readline object or adapter 221 // readline object or adapter
222 StreamResult ReadLine(std::string* line); 222 StreamResult ReadLine(std::string* line);
223 223
224 protected: 224 protected:
225 StreamInterface(); 225 StreamInterface();
226 226
227 // MessageHandler Interface 227 // MessageHandler Interface
228 void OnMessage(Message* msg) override; 228 void OnMessage(Message* msg) override;
229 229
230 private: 230 private:
231 DISALLOW_COPY_AND_ASSIGN(StreamInterface); 231 RTC_DISALLOW_COPY_AND_ASSIGN(StreamInterface);
232 }; 232 };
233 233
234 /////////////////////////////////////////////////////////////////////////////// 234 ///////////////////////////////////////////////////////////////////////////////
235 // StreamAdapterInterface is a convenient base-class for adapting a stream. 235 // StreamAdapterInterface is a convenient base-class for adapting a stream.
236 // By default, all operations are pass-through. Override the methods that you 236 // By default, all operations are pass-through. Override the methods that you
237 // require adaptation. Streams should really be upgraded to reference-counted. 237 // require adaptation. Streams should really be upgraded to reference-counted.
238 // In the meantime, use the owned flag to indicate whether the adapter should 238 // In the meantime, use the owned flag to indicate whether the adapter should
239 // own the adapted stream. 239 // own the adapted stream.
240 /////////////////////////////////////////////////////////////////////////////// 240 ///////////////////////////////////////////////////////////////////////////////
241 241
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 ~StreamAdapterInterface() override; 298 ~StreamAdapterInterface() override;
299 299
300 // Note that the adapter presents itself as the origin of the stream events, 300 // Note that the adapter presents itself as the origin of the stream events,
301 // since users of the adapter may not recognize the adapted object. 301 // since users of the adapter may not recognize the adapted object.
302 virtual void OnEvent(StreamInterface* stream, int events, int err); 302 virtual void OnEvent(StreamInterface* stream, int events, int err);
303 StreamInterface* stream() { return stream_; } 303 StreamInterface* stream() { return stream_; }
304 304
305 private: 305 private:
306 StreamInterface* stream_; 306 StreamInterface* stream_;
307 bool owned_; 307 bool owned_;
308 DISALLOW_COPY_AND_ASSIGN(StreamAdapterInterface); 308 RTC_DISALLOW_COPY_AND_ASSIGN(StreamAdapterInterface);
309 }; 309 };
310 310
311 /////////////////////////////////////////////////////////////////////////////// 311 ///////////////////////////////////////////////////////////////////////////////
312 // StreamTap is a non-modifying, pass-through adapter, which copies all data 312 // StreamTap is a non-modifying, pass-through adapter, which copies all data
313 // in either direction to the tap. Note that errors or blocking on writing to 313 // in either direction to the tap. Note that errors or blocking on writing to
314 // the tap will prevent further tap writes from occurring. 314 // the tap will prevent further tap writes from occurring.
315 /////////////////////////////////////////////////////////////////////////////// 315 ///////////////////////////////////////////////////////////////////////////////
316 316
317 class StreamTap : public StreamAdapterInterface { 317 class StreamTap : public StreamAdapterInterface {
318 public: 318 public:
(...skipping 11 matching lines...) Expand all
330 int* error) override; 330 int* error) override;
331 StreamResult Write(const void* data, 331 StreamResult Write(const void* data,
332 size_t data_len, 332 size_t data_len,
333 size_t* written, 333 size_t* written,
334 int* error) override; 334 int* error) override;
335 335
336 private: 336 private:
337 scoped_ptr<StreamInterface> tap_; 337 scoped_ptr<StreamInterface> tap_;
338 StreamResult tap_result_; 338 StreamResult tap_result_;
339 int tap_error_; 339 int tap_error_;
340 DISALLOW_COPY_AND_ASSIGN(StreamTap); 340 RTC_DISALLOW_COPY_AND_ASSIGN(StreamTap);
341 }; 341 };
342 342
343 /////////////////////////////////////////////////////////////////////////////// 343 ///////////////////////////////////////////////////////////////////////////////
344 // NullStream gives errors on read, and silently discards all written data. 344 // NullStream gives errors on read, and silently discards all written data.
345 /////////////////////////////////////////////////////////////////////////////// 345 ///////////////////////////////////////////////////////////////////////////////
346 346
347 class NullStream : public StreamInterface { 347 class NullStream : public StreamInterface {
348 public: 348 public:
349 NullStream(); 349 NullStream();
350 ~NullStream() override; 350 ~NullStream() override;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 408
409 // Note: Deprecated in favor of Filesystem::GetFileSize(). 409 // Note: Deprecated in favor of Filesystem::GetFileSize().
410 static bool GetSize(const std::string& filename, size_t* size); 410 static bool GetSize(const std::string& filename, size_t* size);
411 411
412 protected: 412 protected:
413 virtual void DoClose(); 413 virtual void DoClose();
414 414
415 FILE* file_; 415 FILE* file_;
416 416
417 private: 417 private:
418 DISALLOW_COPY_AND_ASSIGN(FileStream); 418 RTC_DISALLOW_COPY_AND_ASSIGN(FileStream);
419 }; 419 };
420 420
421 /////////////////////////////////////////////////////////////////////////////// 421 ///////////////////////////////////////////////////////////////////////////////
422 // MemoryStream is a simple implementation of a StreamInterface over in-memory 422 // MemoryStream is a simple implementation of a StreamInterface over in-memory
423 // data. Data is read and written at the current seek position. Reads return 423 // data. Data is read and written at the current seek position. Reads return
424 // end-of-stream when they reach the end of data. Writes actually extend the 424 // end-of-stream when they reach the end of data. Writes actually extend the
425 // end of data mark. 425 // end of data mark.
426 /////////////////////////////////////////////////////////////////////////////// 426 ///////////////////////////////////////////////////////////////////////////////
427 427
428 class MemoryStreamBase : public StreamInterface { 428 class MemoryStreamBase : public StreamInterface {
(...skipping 22 matching lines...) Expand all
451 451
452 virtual StreamResult DoReserve(size_t size, int* error); 452 virtual StreamResult DoReserve(size_t size, int* error);
453 453
454 // Invariant: 0 <= seek_position <= data_length_ <= buffer_length_ 454 // Invariant: 0 <= seek_position <= data_length_ <= buffer_length_
455 char* buffer_; 455 char* buffer_;
456 size_t buffer_length_; 456 size_t buffer_length_;
457 size_t data_length_; 457 size_t data_length_;
458 size_t seek_position_; 458 size_t seek_position_;
459 459
460 private: 460 private:
461 DISALLOW_COPY_AND_ASSIGN(MemoryStreamBase); 461 RTC_DISALLOW_COPY_AND_ASSIGN(MemoryStreamBase);
462 }; 462 };
463 463
464 // MemoryStream dynamically resizes to accomodate written data. 464 // MemoryStream dynamically resizes to accomodate written data.
465 465
466 class MemoryStream : public MemoryStreamBase { 466 class MemoryStream : public MemoryStreamBase {
467 public: 467 public:
468 MemoryStream(); 468 MemoryStream();
469 explicit MemoryStream(const char* data); // Calls SetData(data, strlen(data)) 469 explicit MemoryStream(const char* data); // Calls SetData(data, strlen(data))
470 MemoryStream(const void* data, size_t length); // Calls SetData(data, length) 470 MemoryStream(const void* data, size_t length); // Calls SetData(data, length)
471 ~MemoryStream() override; 471 ~MemoryStream() override;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 StreamResult WriteOffsetLocked(const void* buffer, size_t bytes, 549 StreamResult WriteOffsetLocked(const void* buffer, size_t bytes,
550 size_t offset, size_t* bytes_written); 550 size_t offset, size_t* bytes_written);
551 551
552 StreamState state_; // keeps the opened/closed state of the stream 552 StreamState state_; // keeps the opened/closed state of the stream
553 scoped_ptr<char[]> buffer_; // the allocated buffer 553 scoped_ptr<char[]> buffer_; // the allocated buffer
554 size_t buffer_length_; // size of the allocated buffer 554 size_t buffer_length_; // size of the allocated buffer
555 size_t data_length_; // amount of readable data in the buffer 555 size_t data_length_; // amount of readable data in the buffer
556 size_t read_position_; // offset to the readable data 556 size_t read_position_; // offset to the readable data
557 Thread* owner_; // stream callbacks are dispatched on this thread 557 Thread* owner_; // stream callbacks are dispatched on this thread
558 mutable CriticalSection crit_; // object lock 558 mutable CriticalSection crit_; // object lock
559 DISALLOW_COPY_AND_ASSIGN(FifoBuffer); 559 RTC_DISALLOW_COPY_AND_ASSIGN(FifoBuffer);
560 }; 560 };
561 561
562 /////////////////////////////////////////////////////////////////////////////// 562 ///////////////////////////////////////////////////////////////////////////////
563 563
564 class LoggingAdapter : public StreamAdapterInterface { 564 class LoggingAdapter : public StreamAdapterInterface {
565 public: 565 public:
566 LoggingAdapter(StreamInterface* stream, LoggingSeverity level, 566 LoggingAdapter(StreamInterface* stream, LoggingSeverity level,
567 const std::string& label, bool hex_mode = false); 567 const std::string& label, bool hex_mode = false);
568 568
569 void set_label(const std::string& label); 569 void set_label(const std::string& label);
(...skipping 10 matching lines...) Expand all
580 580
581 protected: 581 protected:
582 void OnEvent(StreamInterface* stream, int events, int err) override; 582 void OnEvent(StreamInterface* stream, int events, int err) override;
583 583
584 private: 584 private:
585 LoggingSeverity level_; 585 LoggingSeverity level_;
586 std::string label_; 586 std::string label_;
587 bool hex_mode_; 587 bool hex_mode_;
588 LogMultilineState lms_; 588 LogMultilineState lms_;
589 589
590 DISALLOW_COPY_AND_ASSIGN(LoggingAdapter); 590 RTC_DISALLOW_COPY_AND_ASSIGN(LoggingAdapter);
591 }; 591 };
592 592
593 /////////////////////////////////////////////////////////////////////////////// 593 ///////////////////////////////////////////////////////////////////////////////
594 // StringStream - Reads/Writes to an external std::string 594 // StringStream - Reads/Writes to an external std::string
595 /////////////////////////////////////////////////////////////////////////////// 595 ///////////////////////////////////////////////////////////////////////////////
596 596
597 class StringStream : public StreamInterface { 597 class StringStream : public StreamInterface {
598 public: 598 public:
599 explicit StringStream(std::string* str); 599 explicit StringStream(std::string* str);
600 explicit StringStream(const std::string& str); 600 explicit StringStream(const std::string& str);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 } 663 }
664 if (ref_count == 0) { 664 if (ref_count == 0) {
665 delete stream_; 665 delete stream_;
666 delete this; 666 delete this;
667 } 667 }
668 } 668 }
669 private: 669 private:
670 StreamInterface* stream_; 670 StreamInterface* stream_;
671 int ref_count_; 671 int ref_count_;
672 CriticalSection cs_; 672 CriticalSection cs_;
673 DISALLOW_COPY_AND_ASSIGN(StreamRefCount); 673 RTC_DISALLOW_COPY_AND_ASSIGN(StreamRefCount);
674 }; 674 };
675 675
676 // Constructor for adding references 676 // Constructor for adding references
677 explicit StreamReference(StreamRefCount* stream_ref_count, 677 explicit StreamReference(StreamRefCount* stream_ref_count,
678 StreamInterface* stream); 678 StreamInterface* stream);
679 679
680 StreamRefCount* stream_ref_count_; 680 StreamRefCount* stream_ref_count_;
681 DISALLOW_COPY_AND_ASSIGN(StreamReference); 681 RTC_DISALLOW_COPY_AND_ASSIGN(StreamReference);
682 }; 682 };
683 683
684 /////////////////////////////////////////////////////////////////////////////// 684 ///////////////////////////////////////////////////////////////////////////////
685 685
686 // Flow attempts to move bytes from source to sink via buffer of size 686 // Flow attempts to move bytes from source to sink via buffer of size
687 // buffer_len. The function returns SR_SUCCESS when source reaches 687 // buffer_len. The function returns SR_SUCCESS when source reaches
688 // end-of-stream (returns SR_EOS), and all the data has been written successful 688 // end-of-stream (returns SR_EOS), and all the data has been written successful
689 // to sink. Alternately, if source returns SR_BLOCK or SR_ERROR, or if sink 689 // to sink. Alternately, if source returns SR_BLOCK or SR_ERROR, or if sink
690 // returns SR_BLOCK, SR_ERROR, or SR_EOS, then the function immediately returns 690 // returns SR_BLOCK, SR_ERROR, or SR_EOS, then the function immediately returns
691 // with the unexpected StreamResult value. 691 // with the unexpected StreamResult value.
692 // data_len is the length of the valid data in buffer. in case of error 692 // data_len is the length of the valid data in buffer. in case of error
693 // this is the data that read from source but can't move to destination. 693 // this is the data that read from source but can't move to destination.
694 // as a pass in parameter, it indicates data in buffer that should move to sink 694 // as a pass in parameter, it indicates data in buffer that should move to sink
695 StreamResult Flow(StreamInterface* source, 695 StreamResult Flow(StreamInterface* source,
696 char* buffer, size_t buffer_len, 696 char* buffer, size_t buffer_len,
697 StreamInterface* sink, size_t* data_len = NULL); 697 StreamInterface* sink, size_t* data_len = NULL);
698 698
699 /////////////////////////////////////////////////////////////////////////////// 699 ///////////////////////////////////////////////////////////////////////////////
700 700
701 } // namespace rtc 701 } // namespace rtc
702 702
703 #endif // WEBRTC_BASE_STREAM_H_ 703 #endif // WEBRTC_BASE_STREAM_H_
OLDNEW
« no previous file with comments | « webrtc/base/sslidentity.h ('k') | webrtc/base/task_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698