| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/spdy/hpack/hpack_constants.h" | 5 #include "net/spdy/hpack/hpack_constants.h" | 
| 6 | 6 | 
| 7 #include <vector> | 7 #include <vector> | 
| 8 | 8 | 
| 9 #include "base/logging.h" | 9 #include "base/logging.h" | 
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 22  public: | 22  public: | 
| 23   SharedHpackHuffmanTable() { | 23   SharedHpackHuffmanTable() { | 
| 24     std::vector<HpackHuffmanSymbol> code = HpackHuffmanCode(); | 24     std::vector<HpackHuffmanSymbol> code = HpackHuffmanCode(); | 
| 25     scoped_ptr<HpackHuffmanTable> mutable_table(new HpackHuffmanTable()); | 25     scoped_ptr<HpackHuffmanTable> mutable_table(new HpackHuffmanTable()); | 
| 26     CHECK(mutable_table->Initialize(&code[0], code.size())); | 26     CHECK(mutable_table->Initialize(&code[0], code.size())); | 
| 27     CHECK(mutable_table->IsInitialized()); | 27     CHECK(mutable_table->IsInitialized()); | 
| 28     table.reset(mutable_table.release()); | 28     table.reset(mutable_table.release()); | 
| 29   } | 29   } | 
| 30 | 30 | 
| 31   static SharedHpackHuffmanTable* GetInstance() { | 31   static SharedHpackHuffmanTable* GetInstance() { | 
| 32     return Singleton<SharedHpackHuffmanTable>::get(); | 32     return base::Singleton<SharedHpackHuffmanTable>::get(); | 
| 33   } | 33   } | 
| 34 | 34 | 
| 35   scoped_ptr<const HpackHuffmanTable> table; | 35   scoped_ptr<const HpackHuffmanTable> table; | 
| 36 }; | 36 }; | 
| 37 | 37 | 
| 38 // SharedHpackStaticTable is a Singleton wrapping a HpackStaticTable | 38 // SharedHpackStaticTable is a Singleton wrapping a HpackStaticTable | 
| 39 // instance initialized with |kHpackStaticTable|. | 39 // instance initialized with |kHpackStaticTable|. | 
| 40 struct SharedHpackStaticTable { | 40 struct SharedHpackStaticTable { | 
| 41  public: | 41  public: | 
| 42   SharedHpackStaticTable() { | 42   SharedHpackStaticTable() { | 
| 43     std::vector<HpackStaticEntry> static_table = HpackStaticTableVector(); | 43     std::vector<HpackStaticEntry> static_table = HpackStaticTableVector(); | 
| 44     scoped_ptr<HpackStaticTable> mutable_table(new HpackStaticTable()); | 44     scoped_ptr<HpackStaticTable> mutable_table(new HpackStaticTable()); | 
| 45     mutable_table->Initialize(&static_table[0], static_table.size()); | 45     mutable_table->Initialize(&static_table[0], static_table.size()); | 
| 46     CHECK(mutable_table->IsInitialized()); | 46     CHECK(mutable_table->IsInitialized()); | 
| 47     table.reset(mutable_table.release()); | 47     table.reset(mutable_table.release()); | 
| 48   } | 48   } | 
| 49 | 49 | 
| 50   static SharedHpackStaticTable* GetInstance() { | 50   static SharedHpackStaticTable* GetInstance() { | 
| 51     return Singleton<SharedHpackStaticTable>::get(); | 51     return base::Singleton<SharedHpackStaticTable>::get(); | 
| 52   } | 52   } | 
| 53 | 53 | 
| 54   scoped_ptr<const HpackStaticTable> table; | 54   scoped_ptr<const HpackStaticTable> table; | 
| 55 }; | 55 }; | 
| 56 | 56 | 
| 57 }  // namespace | 57 }  // namespace | 
| 58 | 58 | 
| 59 // Produced by applying the python program [1] with tables | 59 // Produced by applying the python program [1] with tables | 
| 60 // provided by [2] (inserted into the source of the python program) | 60 // provided by [2] (inserted into the source of the python program) | 
| 61 // and copy-paste them into this file. | 61 // and copy-paste them into this file. | 
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 406 | 406 | 
| 407 const HpackHuffmanTable& ObtainHpackHuffmanTable() { | 407 const HpackHuffmanTable& ObtainHpackHuffmanTable() { | 
| 408   return *SharedHpackHuffmanTable::GetInstance()->table; | 408   return *SharedHpackHuffmanTable::GetInstance()->table; | 
| 409 } | 409 } | 
| 410 | 410 | 
| 411 const HpackStaticTable& ObtainHpackStaticTable() { | 411 const HpackStaticTable& ObtainHpackStaticTable() { | 
| 412   return *SharedHpackStaticTable::GetInstance()->table; | 412   return *SharedHpackStaticTable::GetInstance()->table; | 
| 413 } | 413 } | 
| 414 | 414 | 
| 415 }  // namespace net | 415 }  // namespace net | 
| OLD | NEW | 
|---|