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

Side by Side Diff: net/spdy/hpack/hpack_constants.cc

Issue 1308823002: Move Singleton and related structs to namespace base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ToT 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 | « net/socket/websocket_endpoint_lock_manager.cc ('k') | net/ssl/openssl_client_key_store.h » ('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 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
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
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
OLDNEW
« no previous file with comments | « net/socket/websocket_endpoint_lock_manager.cc ('k') | net/ssl/openssl_client_key_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698