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

Unified Diff: src/profile-generator.h

Issue 2769001: Factor out StringsStorage from CpuProfilesCollection. (Closed)
Patch Set: Comments addressed Created 10 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/profile-generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/profile-generator.h
diff --git a/src/profile-generator.h b/src/profile-generator.h
index d39974ed0ee70b8d8402898800b11cbbb7624bae..be0e94ea1983fa0f13344a67efc76e498a634891 100644
--- a/src/profile-generator.h
+++ b/src/profile-generator.h
@@ -56,6 +56,28 @@ class TokenEnumerator {
};
+// Provides a storage of strings allocated in C++ heap, to hold them
+// forever, even if they disappear from JS heap or external storage.
+class StringsStorage {
+ public:
+ StringsStorage();
+ ~StringsStorage();
+
+ const char* GetName(String* name);
+
+ private:
+ INLINE(static bool StringsMatch(void* key1, void* key2)) {
+ return strcmp(reinterpret_cast<char*>(key1),
+ reinterpret_cast<char*>(key2)) == 0;
+ }
+
+ // String::Hash -> const char*
+ HashMap names_;
+
+ DISALLOW_COPY_AND_ASSIGN(StringsStorage);
+};
+
+
class CodeEntry {
public:
explicit INLINE(CodeEntry(int security_token_id));
@@ -258,10 +280,12 @@ class CpuProfilesCollection {
String* title,
double actual_sampling_rate);
List<CpuProfile*>* Profiles(int security_token_id);
+ const char* GetName(String* name) {
+ return function_and_resource_names_.GetName(name);
+ }
CpuProfile* GetProfile(int security_token_id, unsigned uid);
inline bool is_last_profile();
- const char* GetName(String* name);
CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag,
String* name, String* resource_name, int line_number);
CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name);
@@ -280,17 +304,11 @@ class CpuProfilesCollection {
List<CpuProfile*>* GetProfilesList(int security_token_id);
int TokenToIndex(int security_token_id);
- INLINE(static bool StringsMatch(void* key1, void* key2)) {
- return strcmp(reinterpret_cast<char*>(key1),
- reinterpret_cast<char*>(key2)) == 0;
- }
-
INLINE(static bool UidsMatch(void* key1, void* key2)) {
return key1 == key2;
}
- // String::Hash -> const char*
- HashMap function_and_resource_names_;
+ StringsStorage function_and_resource_names_;
// args_count -> char*
List<char*> args_count_names_;
List<CodeEntry*> code_entries_;
« no previous file with comments | « no previous file | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698