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

Side by Side Diff: src/platform.h

Issue 27085: Add socket support to platform code.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « SConstruct ('k') | src/platform-freebsd.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 #undef INFINITY 102 #undef INFINITY
103 #define INFINITY std::numeric_limits<double>::infinity() 103 #define INFINITY std::numeric_limits<double>::infinity()
104 #endif 104 #endif
105 105
106 #endif // __GNUC__ 106 #endif // __GNUC__
107 107
108 namespace v8 { namespace internal { 108 namespace v8 { namespace internal {
109 109
110 double ceiling(double x); 110 double ceiling(double x);
111 111
112 // Forward declarations.
113 class Socket;
114
112 // ---------------------------------------------------------------------------- 115 // ----------------------------------------------------------------------------
113 // OS 116 // OS
114 // 117 //
115 // This class has static methods for the different platform specific 118 // This class has static methods for the different platform specific
116 // functions. Add methods here to cope with differences between the 119 // functions. Add methods here to cope with differences between the
117 // supported platforms. 120 // supported platforms.
118 121
119 class OS { 122 class OS {
120 public: 123 public:
121 // Initializes the platform OS support. Called once at VM startup. 124 // Initializes the platform OS support. Called once at VM startup.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 static int StackWalk(StackFrame* frames, int frames_size); 201 static int StackWalk(StackFrame* frames, int frames_size);
199 202
200 // Factory method for creating platform dependent Mutex. 203 // Factory method for creating platform dependent Mutex.
201 // Please use delete to reclaim the storage for the returned Mutex. 204 // Please use delete to reclaim the storage for the returned Mutex.
202 static Mutex* CreateMutex(); 205 static Mutex* CreateMutex();
203 206
204 // Factory method for creating platform dependent Semaphore. 207 // Factory method for creating platform dependent Semaphore.
205 // Please use delete to reclaim the storage for the returned Semaphore. 208 // Please use delete to reclaim the storage for the returned Semaphore.
206 static Semaphore* CreateSemaphore(int count); 209 static Semaphore* CreateSemaphore(int count);
207 210
211 // Factory method for creating platform dependent Socket.
212 // Please use delete to reclaim the storage for the returned Socket.
213 static Socket* CreateSocket();
214
208 class MemoryMappedFile { 215 class MemoryMappedFile {
209 public: 216 public:
210 static MemoryMappedFile* create(const char* name, int size, void* initial); 217 static MemoryMappedFile* create(const char* name, int size, void* initial);
211 virtual ~MemoryMappedFile() { } 218 virtual ~MemoryMappedFile() { }
212 virtual void* memory() = 0; 219 virtual void* memory() = 0;
213 }; 220 };
214 221
215 // Safe formatting print. Ensures that str is always null-terminated. 222 // Safe formatting print. Ensures that str is always null-terminated.
216 // Returns the number of chars written, or -1 if output was truncated. 223 // Returns the number of chars written, or -1 if output was truncated.
217 static int SNPrintF(Vector<char> str, const char* format, ...); 224 static int SNPrintF(Vector<char> str, const char* format, ...);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 412
406 // Suspends the calling thread until the counter is non zero 413 // Suspends the calling thread until the counter is non zero
407 // and then decrements the semaphore counter. 414 // and then decrements the semaphore counter.
408 virtual void Wait() = 0; 415 virtual void Wait() = 0;
409 416
410 // Increments the semaphore counter. 417 // Increments the semaphore counter.
411 virtual void Signal() = 0; 418 virtual void Signal() = 0;
412 }; 419 };
413 420
414 421
422 // ----------------------------------------------------------------------------
423 // Socket
424 //
425
426 class Socket {
427 public:
428 virtual ~Socket() {}
429
430 // Server initialization.
431 virtual bool Bind (const int port) = 0;
432 virtual bool Listen(int backlog) const = 0;
433 virtual Socket* Accept() const = 0;
434
435 // Client initialization.
436 virtual bool Connect(const char* host, const char* port) = 0;
437
438 // Data Transimission
439 virtual int Send(const char* data, int len) const = 0;
440 virtual bool SendAll(const char* data, int len) const = 0;
441 virtual int Receive(char* data, int len) const = 0;
442
443 virtual bool IsValid() const = 0;
444
445 static bool Setup();
446 static int LastError();
447 static uint16_t HToN(uint16_t value);
448 static uint16_t NToH(uint16_t value);
449 static uint32_t HToN(uint32_t value);
450 static uint32_t NToH(uint32_t value);
451 };
452
453
415 #ifdef ENABLE_LOGGING_AND_PROFILING 454 #ifdef ENABLE_LOGGING_AND_PROFILING
416 // ---------------------------------------------------------------------------- 455 // ----------------------------------------------------------------------------
417 // Sampler 456 // Sampler
418 // 457 //
419 // A sampler periodically samples the state of the VM and optionally 458 // A sampler periodically samples the state of the VM and optionally
420 // (if used for profiling) the program counter and stack pointer for 459 // (if used for profiling) the program counter and stack pointer for
421 // the thread that created it. 460 // the thread that created it.
422 461
423 // TickSample captures the information collected for each sample. 462 // TickSample captures the information collected for each sample.
424 class TickSample { 463 class TickSample {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 bool active_; 514 bool active_;
476 PlatformData* data_; // Platform specific data. 515 PlatformData* data_; // Platform specific data.
477 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 516 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
478 }; 517 };
479 518
480 #endif // ENABLE_LOGGING_AND_PROFILING 519 #endif // ENABLE_LOGGING_AND_PROFILING
481 520
482 } } // namespace v8::internal 521 } } // namespace v8::internal
483 522
484 #endif // V8_PLATFORM_H_ 523 #endif // V8_PLATFORM_H_
OLDNEW
« no previous file with comments | « SConstruct ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698