equal
deleted
inserted
replaced
|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
|
2 // Use of this source code is governed by a BSD-style license that can be |
|
3 // found in the LICENSE file. |
|
4 |
|
5 package org.chromium.sdk; |
|
6 |
|
7 /** |
|
8 * Helper class for experimental support of LiveEdit feature. While regular API does not |
|
9 * support LiveEdit (not to break compatibility with existing clients), it gives access to extended |
|
10 * interfaces. |
|
11 * <p> |
|
12 * This class encapsulates all instanceofs/casts that are considered to be untrackable |
|
13 * in the main code and therefore harmful. |
|
14 */ |
|
15 public class LiveEditExtension { |
|
16 /** |
|
17 * Casts script to the interface that supports updating source on remote VM. |
|
18 * @return extended interface or null if unsupported |
|
19 */ |
|
20 public static UpdatableScript castToUpdatableScript(Script script) { |
|
21 if (script instanceof UpdatableScript == false) { |
|
22 return null; |
|
23 } |
|
24 return (UpdatableScript) script; |
|
25 } |
|
26 |
|
27 /** |
|
28 * Casts listener to interface that accepts LiveEdit-related events. |
|
29 * @return extended interface or null if unsupported |
|
30 */ |
|
31 public static LiveEditDebugEventListener castToLiveEditListener( |
|
32 DebugEventListener debugEventListener) { |
|
33 if (debugEventListener instanceof LiveEditDebugEventListener == false) { |
|
34 return null; |
|
35 } |
|
36 return (LiveEditDebugEventListener) debugEventListener; |
|
37 } |
|
38 } |