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

Side by Side Diff: chrome/common/extensions/extension_messages.cc

Issue 7347011: Update URLPatternSet to contain a std::set instead of std::vector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows compile errors. Created 9 years, 5 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/common/extensions/extension_messages.h" 5 #include "chrome/common/extensions/extension_messages.h"
6 6
7 #include "chrome/common/extensions/extension_constants.h" 7 #include "chrome/common/extensions/extension_constants.h"
8 #include "content/common/common_param_traits.h" 8 #include "content/common/common_param_traits.h"
9 9
10 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params() 10 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params()
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 92 }
93 93
94 bool ParamTraits<URLPattern>::Read(const Message* m, void** iter, 94 bool ParamTraits<URLPattern>::Read(const Message* m, void** iter,
95 param_type* p) { 95 param_type* p) {
96 int valid_schemes; 96 int valid_schemes;
97 std::string spec; 97 std::string spec;
98 if (!ReadParam(m, iter, &valid_schemes) || 98 if (!ReadParam(m, iter, &valid_schemes) ||
99 !ReadParam(m, iter, &spec)) 99 !ReadParam(m, iter, &spec))
100 return false; 100 return false;
101 101
102 p->set_valid_schemes(valid_schemes); 102 p->SetValidSchemes(valid_schemes);
103 return URLPattern::PARSE_SUCCESS == p->Parse(spec, URLPattern::IGNORE_PORTS); 103 return URLPattern::PARSE_SUCCESS == p->Parse(spec, URLPattern::IGNORE_PORTS);
104 } 104 }
105 105
106 void ParamTraits<URLPattern>::Log(const param_type& p, std::string* l) { 106 void ParamTraits<URLPattern>::Log(const param_type& p, std::string* l) {
107 LogParam(p.GetAsString(), l); 107 LogParam(p.GetAsString(), l);
108 } 108 }
109 109
110 void ParamTraits<URLPatternSet>::Write(Message* m, const param_type& p) { 110 void ParamTraits<URLPatternSet>::Write(Message* m, const param_type& p) {
111 WriteParam(m, p.patterns()); 111 WriteParam(m, p.patterns());
112 } 112 }
113 113
114 bool ParamTraits<URLPatternSet>::Read(const Message* m, void** iter, 114 bool ParamTraits<URLPatternSet>::Read(const Message* m, void** iter,
115 param_type* p) { 115 param_type* p) {
116 URLPatternList patterns; 116 std::set<URLPattern> patterns;
117 bool success = 117 bool success =
118 ReadParam(m, iter, &patterns); 118 ReadParam(m, iter, &patterns);
119 if (!success) 119 if (!success)
120 return false; 120 return false;
121 121
122 for (size_t i = 0; i < patterns.size(); ++i) 122 for (std::set<URLPattern>::iterator i = patterns.begin();
123 p->AddPattern(patterns[i]); 123 i != patterns.end(); ++i)
124 p->AddPattern(*i);
124 return true; 125 return true;
125 } 126 }
126 127
127 void ParamTraits<URLPatternSet>::Log(const param_type& p, std::string* l) { 128 void ParamTraits<URLPatternSet>::Log(const param_type& p, std::string* l) {
128 LogParam(p.patterns(), l); 129 LogParam(p.patterns(), l);
129 } 130 }
130 131
131 void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m, 132 void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m,
132 const param_type& p) { 133 const param_type& p) {
133 WriteParam(m, p.location); 134 WriteParam(m, p.location);
134 WriteParam(m, p.path); 135 WriteParam(m, p.path);
135 WriteParam(m, *(p.manifest)); 136 WriteParam(m, *(p.manifest));
136 } 137 }
137 138
138 bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const Message* m, 139 bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const Message* m,
139 void** iter, 140 void** iter,
140 param_type* p) { 141 param_type* p) {
141 p->manifest.reset(new DictionaryValue()); 142 p->manifest.reset(new DictionaryValue());
142 return ReadParam(m, iter, &p->location) && 143 return ReadParam(m, iter, &p->location) &&
143 ReadParam(m, iter, &p->path) && 144 ReadParam(m, iter, &p->path) &&
144 ReadParam(m, iter, p->manifest.get()); 145 ReadParam(m, iter, p->manifest.get());
145 } 146 }
146 147
147 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p, 148 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p,
148 std::string* l) { 149 std::string* l) {
149 l->append(p.id); 150 l->append(p.id);
150 } 151 }
151 152
152 } // namespace IPC 153 } // namespace IPC
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_manifests_unittest.cc ('k') | chrome/common/extensions/extension_permission_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698