| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 // static | 44 // static |
| 45 String IdentifiersFactory::CreateIdentifier() { | 45 String IdentifiersFactory::CreateIdentifier() { |
| 46 int identifier = AtomicIncrement(&g_last_used_identifier); | 46 int identifier = AtomicIncrement(&g_last_used_identifier); |
| 47 return AddProcessIdPrefixTo(identifier); | 47 return AddProcessIdPrefixTo(identifier); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // static | 50 // static |
| 51 String IdentifiersFactory::RequestId(unsigned long identifier) { | 51 String IdentifiersFactory::RequestId(unsigned long identifier) { |
| 52 // Odd request Ids are set by the browser. For those we use a PID of 0 |
| 53 // because for browser side navigations the PID may not be known when an event |
| 54 // is sent because the renderer hasn't been created yet. |
| 55 int signed_identifier = static_cast<int>(identifier); |
| 56 if (signed_identifier < 0) { |
| 57 StringBuilder builder; |
| 58 builder.Append("0."); |
| 59 builder.AppendNumber(signed_identifier); |
| 60 return builder.ToString(); |
| 61 } |
| 52 return identifier ? AddProcessIdPrefixTo(identifier) : String(); | 62 return identifier ? AddProcessIdPrefixTo(identifier) : String(); |
| 53 } | 63 } |
| 54 | 64 |
| 55 // static | 65 // static |
| 56 String IdentifiersFactory::FrameId(LocalFrame* frame) { | 66 String IdentifiersFactory::FrameId(LocalFrame* frame) { |
| 57 return AddProcessIdPrefixTo(WeakIdentifierMap<LocalFrame>::Identifier(frame)); | 67 return AddProcessIdPrefixTo(WeakIdentifierMap<LocalFrame>::Identifier(frame)); |
| 58 } | 68 } |
| 59 | 69 |
| 60 // static | 70 // static |
| 61 LocalFrame* IdentifiersFactory::FrameById(InspectedFrames* inspected_frames, | 71 LocalFrame* IdentifiersFactory::FrameById(InspectedFrames* inspected_frames, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 size_t dot_index = id.Find('.'); | 117 size_t dot_index = id.Find('.'); |
| 108 | 118 |
| 109 if (dot_index == kNotFound) { | 119 if (dot_index == kNotFound) { |
| 110 *ok = false; | 120 *ok = false; |
| 111 return 0; | 121 return 0; |
| 112 } | 122 } |
| 113 return id.Substring(dot_index + 1).ToInt(ok); | 123 return id.Substring(dot_index + 1).ToInt(ok); |
| 114 } | 124 } |
| 115 | 125 |
| 116 } // namespace blink | 126 } // namespace blink |
| OLD | NEW |