| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <windows.h> | 5 #include <windows.h> |
| 6 #include <mmsystem.h> | 6 #include <mmsystem.h> |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 ::VirtualQuery(start_, &mbi, sizeof(mbi)); | 131 ::VirtualQuery(start_, &mbi, sizeof(mbi)); |
| 132 size_ = mbi.RegionSize; | 132 size_ = mbi.RegionSize; |
| 133 } | 133 } |
| 134 ~ReadOnlyMappedFile() { | 134 ~ReadOnlyMappedFile() { |
| 135 if (start_) { | 135 if (start_) { |
| 136 ::UnmapViewOfFile(start_); | 136 ::UnmapViewOfFile(start_); |
| 137 ::CloseHandle(fmap_); | 137 ::CloseHandle(fmap_); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 // Returns true if the file was successfully mapped. | 140 // Returns true if the file was successfully mapped. |
| 141 bool is_valid() const { | 141 bool is_valid() const { return (start_ && (size_ > 0)); } |
| 142 return ((start_ > 0) && (size_ > 0)); | |
| 143 } | |
| 144 // Returns the size in bytes of the mapped memory. | 142 // Returns the size in bytes of the mapped memory. |
| 145 uint32_t size() const { return size_; } | 143 uint32_t size() const { return size_; } |
| 146 // Returns the memory backing the file. | 144 // Returns the memory backing the file. |
| 147 const void* GetChunkAt(uint32_t offset) { return &start_[offset]; } | 145 const void* GetChunkAt(uint32_t offset) { return &start_[offset]; } |
| 148 | 146 |
| 149 private: | 147 private: |
| 150 HANDLE fmap_; | 148 HANDLE fmap_; |
| 151 char* start_; | 149 char* start_; |
| 152 uint32_t size_; | 150 uint32_t size_; |
| 153 }; | 151 }; |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 oas->Start(&source); | 650 oas->Start(&source); |
| 653 | 651 |
| 654 ::WaitForSingleObject(thread, INFINITE); | 652 ::WaitForSingleObject(thread, INFINITE); |
| 655 ::CloseHandle(thread); | 653 ::CloseHandle(thread); |
| 656 | 654 |
| 657 oas->Stop(); | 655 oas->Stop(); |
| 658 oas->Close(); | 656 oas->Close(); |
| 659 } | 657 } |
| 660 | 658 |
| 661 } // namespace media | 659 } // namespace media |
| OLD | NEW |