OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 String IdentifiersFactory::RequestId(unsigned long identifier) { | 51 String IdentifiersFactory::RequestId(unsigned long identifier) { |
52 return identifier ? AddProcessIdPrefixTo(identifier) : String(); | 52 return identifier ? AddProcessIdPrefixTo(identifier) : String(); |
53 } | 53 } |
54 | 54 |
55 // static | 55 // static |
56 String IdentifiersFactory::FrameId(LocalFrame* frame) { | 56 String IdentifiersFactory::FrameId(LocalFrame* frame) { |
57 return AddProcessIdPrefixTo(WeakIdentifierMap<LocalFrame>::Identifier(frame)); | 57 return AddProcessIdPrefixTo(WeakIdentifierMap<LocalFrame>::Identifier(frame)); |
58 } | 58 } |
59 | 59 |
60 // static | 60 // static |
61 String IdentifiersFactory::FrameIdSafe(LocalFrame* frame) { | |
62 return frame ? FrameId(frame) : ""; | |
pfeldman
2017/07/21 18:10:59
Bake it into FrameId(), return String() if nullptr
Daniel Bratell
2017/07/23 20:14:12
Done.
| |
63 } | |
64 | |
65 // static | |
61 LocalFrame* IdentifiersFactory::FrameById(InspectedFrames* inspected_frames, | 66 LocalFrame* IdentifiersFactory::FrameById(InspectedFrames* inspected_frames, |
62 const String& frame_id) { | 67 const String& frame_id) { |
63 bool ok; | 68 bool ok; |
64 int id = RemoveProcessIdPrefixFrom(frame_id, &ok); | 69 int id = RemoveProcessIdPrefixFrom(frame_id, &ok); |
65 if (!ok) | 70 if (!ok) |
66 return nullptr; | 71 return nullptr; |
67 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::Lookup(id); | 72 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::Lookup(id); |
68 return frame && inspected_frames->Contains(frame) ? frame : nullptr; | 73 return frame && inspected_frames->Contains(frame) ? frame : nullptr; |
69 } | 74 } |
70 | 75 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 size_t dot_index = id.find('.'); | 110 size_t dot_index = id.find('.'); |
106 | 111 |
107 if (dot_index == kNotFound) { | 112 if (dot_index == kNotFound) { |
108 *ok = false; | 113 *ok = false; |
109 return 0; | 114 return 0; |
110 } | 115 } |
111 return id.Substring(dot_index + 1).ToInt(ok); | 116 return id.Substring(dot_index + 1).ToInt(ok); |
112 } | 117 } |
113 | 118 |
114 } // namespace blink | 119 } // namespace blink |
OLD | NEW |