{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/stetho/pulls/comments/28983039","id":28983039,"diff_hunk":"@@ -11,38 +11,104 @@\n \n import android.os.Handler;\n import android.os.Looper;\n+import com.facebook.stetho.common.Util;\n+\n+import java.util.concurrent.Callable;\n \n public final class HandlerUtil {\n   private HandlerUtil() {\n   }\n \n-  public static boolean postAndWait(Handler handler, final Runnable r) {\n-    if (Looper.myLooper() == handler.getLooper()) {\n-      r.run();\n-      return true;\n+  /**\n+   * Checks whether the current thread is the same thread that the {@link Handler} is associated\n+   * with.\n+   * @return true if the current thread is the same thread that the {@link Handler} is associated\n+   * with; otherwise false.\n+   */\n+  public static boolean checkAccess(Handler handler) {","path":"stetho/src/main/java/com/facebook/stetho/common/android/HandlerUtil.java","position":22,"original_position":22,"commit_id":"51d0cef7f064c885defcd0de2072f0d44c3f2d74","original_commit_id":"51d0cef7f064c885defcd0de2072f0d44c3f2d74","user":{"login":"rickbrew","id":10873410,"avatar_url":"https://avatars.githubusercontent.com/u/10873410?v=3","gravatar_id":"","url":"https://api.github.com/users/rickbrew","html_url":"https://github.com/rickbrew","followers_url":"https://api.github.com/users/rickbrew/followers","following_url":"https://api.github.com/users/rickbrew/following{/other_user}","gists_url":"https://api.github.com/users/rickbrew/gists{/gist_id}","starred_url":"https://api.github.com/users/rickbrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rickbrew/subscriptions","organizations_url":"https://api.github.com/users/rickbrew/orgs","repos_url":"https://api.github.com/users/rickbrew/repos","events_url":"https://api.github.com/users/rickbrew/events{/privacy}","received_events_url":"https://api.github.com/users/rickbrew/received_events","type":"User","site_admin":false},"body":"WPF uses this extensively and I found it to work quite well: https://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcherobject.checkaccess%28v=vs.110%29.aspx\r\n\r\nPerhaps it would work better with a name like checkThreadAccess(). It is a lot less code when you have to repeat the call in many places; it's intended to be used non-sparingly in order to enforce that code is running on the right thread. It's not really different in principle than something like Util.throwIfNull().","created_at":"2015-04-23T17:17:37Z","updated_at":"2015-04-23T17:17:37Z","html_url":"https://github.com/facebook/stetho/pull/168#discussion_r28983039","pull_request_url":"https://api.github.com/repos/facebook/stetho/pulls/168","_links":{"self":{"href":"https://api.github.com/repos/facebook/stetho/pulls/comments/28983039"},"html":{"href":"https://github.com/facebook/stetho/pull/168#discussion_r28983039"},"pull_request":{"href":"https://api.github.com/repos/facebook/stetho/pulls/168"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/stetho/pulls/168","id":33813980,"html_url":"https://github.com/facebook/stetho/pull/168","diff_url":"https://github.com/facebook/stetho/pull/168.diff","patch_url":"https://github.com/facebook/stetho/pull/168.patch","issue_url":"https://api.github.com/repos/facebook/stetho/issues/168","number":168,"state":"open","locked":false,"title":"Clarify and enforce thread safety contract of DOMProvider et. al.","user":{"login":"rickbrew","id":10873410,"avatar_url":"https://avatars.githubusercontent.com/u/10873410?v=3","gravatar_id":"","url":"https://api.github.com/users/rickbrew","html_url":"https://github.com/rickbrew","followers_url":"https://api.github.com/users/rickbrew/followers","following_url":"https://api.github.com/users/rickbrew/following{/other_user}","gists_url":"https://api.github.com/users/rickbrew/gists{/gist_id}","starred_url":"https://api.github.com/users/rickbrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rickbrew/subscriptions","organizations_url":"https://api.github.com/users/rickbrew/orgs","repos_url":"https://api.github.com/users/rickbrew/repos","events_url":"https://api.github.com/users/rickbrew/events{/privacy}","received_events_url":"https://api.github.com/users/rickbrew/received_events","type":"User","site_admin":false},"body":"This introduces a new interface, ThreadBound, which provides methods for dealing with the UI thread safety contract that we need to enforce w.r.t. Android UI objects. We are also much more stringent about verifying that calls are being made on the correct thread.\r\n\r\nCloses #167","created_at":"2015-04-21T23:36:31Z","updated_at":"2015-04-23T17:17:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a4ea3a1bd7b75a90effd95e5dd5d7591b2286f9e","assignee":{"login":"jasta","id":83791,"avatar_url":"https://avatars.githubusercontent.com/u/83791?v=3","gravatar_id":"","url":"https://api.github.com/users/jasta","html_url":"https://github.com/jasta","followers_url":"https://api.github.com/users/jasta/followers","following_url":"https://api.github.com/users/jasta/following{/other_user}","gists_url":"https://api.github.com/users/jasta/gists{/gist_id}","starred_url":"https://api.github.com/users/jasta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasta/subscriptions","organizations_url":"https://api.github.com/users/jasta/orgs","repos_url":"https://api.github.com/users/jasta/repos","events_url":"https://api.github.com/users/jasta/events{/privacy}","received_events_url":"https://api.github.com/users/jasta/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/facebook/stetho/pulls/168/commits","review_comments_url":"https://api.github.com/repos/facebook/stetho/pulls/168/comments","review_comment_url":"https://api.github.com/repos/facebook/stetho/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/stetho/issues/168/comments","statuses_url":"https://api.github.com/repos/facebook/stetho/statuses/51d0cef7f064c885defcd0de2072f0d44c3f2d74","head":{"label":"rickbrew:domthreading","ref":"domthreading","sha":"51d0cef7f064c885defcd0de2072f0d44c3f2d74","user":{"login":"rickbrew","id":10873410,"avatar_url":"https://avatars.githubusercontent.com/u/10873410?v=3","gravatar_id":"","url":"https://api.github.com/users/rickbrew","html_url":"https://github.com/rickbrew","followers_url":"https://api.github.com/users/rickbrew/followers","following_url":"https://api.github.com/users/rickbrew/following{/other_user}","gists_url":"https://api.github.com/users/rickbrew/gists{/gist_id}","starred_url":"https://api.github.com/users/rickbrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rickbrew/subscriptions","organizations_url":"https://api.github.com/users/rickbrew/orgs","repos_url":"https://api.github.com/users/rickbrew/repos","events_url":"https://api.github.com/users/rickbrew/events{/privacy}","received_events_url":"https://api.github.com/users/rickbrew/received_events","type":"User","site_admin":false},"repo":{"id":30989042,"name":"stetho","full_name":"rickbrew/stetho","owner":{"login":"rickbrew","id":10873410,"avatar_url":"https://avatars.githubusercontent.com/u/10873410?v=3","gravatar_id":"","url":"https://api.github.com/users/rickbrew","html_url":"https://github.com/rickbrew","followers_url":"https://api.github.com/users/rickbrew/followers","following_url":"https://api.github.com/users/rickbrew/following{/other_user}","gists_url":"https://api.github.com/users/rickbrew/gists{/gist_id}","starred_url":"https://api.github.com/users/rickbrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rickbrew/subscriptions","organizations_url":"https://api.github.com/users/rickbrew/orgs","repos_url":"https://api.github.com/users/rickbrew/repos","events_url":"https://api.github.com/users/rickbrew/events{/privacy}","received_events_url":"https://api.github.com/users/rickbrew/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rickbrew/stetho","description":"Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.","fork":true,"url":"https://api.github.com/repos/rickbrew/stetho","forks_url":"https://api.github.com/repos/rickbrew/stetho/forks","keys_url":"https://api.github.com/repos/rickbrew/stetho/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rickbrew/stetho/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rickbrew/stetho/teams","hooks_url":"https://api.github.com/repos/rickbrew/stetho/hooks","issue_events_url":"https://api.github.com/repos/rickbrew/stetho/issues/events{/number}","events_url":"https://api.github.com/repos/rickbrew/stetho/events","assignees_url":"https://api.github.com/repos/rickbrew/stetho/assignees{/user}","branches_url":"https://api.github.com/repos/rickbrew/stetho/branches{/branch}","tags_url":"https://api.github.com/repos/rickbrew/stetho/tags","blobs_url":"https://api.github.com/repos/rickbrew/stetho/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rickbrew/stetho/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rickbrew/stetho/git/refs{/sha}","trees_url":"https://api.github.com/repos/rickbrew/stetho/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rickbrew/stetho/statuses/{sha}","languages_url":"https://api.github.com/repos/rickbrew/stetho/languages","stargazers_url":"https://api.github.com/repos/rickbrew/stetho/stargazers","contributors_url":"https://api.github.com/repos/rickbrew/stetho/contributors","subscribers_url":"https://api.github.com/repos/rickbrew/stetho/subscribers","subscription_url":"https://api.github.com/repos/rickbrew/stetho/subscription","commits_url":"https://api.github.com/repos/rickbrew/stetho/commits{/sha}","git_commits_url":"https://api.github.com/repos/rickbrew/stetho/git/commits{/sha}","comments_url":"https://api.github.com/repos/rickbrew/stetho/comments{/number}","issue_comment_url":"https://api.github.com/repos/rickbrew/stetho/issues/comments{/number}","contents_url":"https://api.github.com/repos/rickbrew/stetho/contents/{+path}","compare_url":"https://api.github.com/repos/rickbrew/stetho/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rickbrew/stetho/merges","archive_url":"https://api.github.com/repos/rickbrew/stetho/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rickbrew/stetho/downloads","issues_url":"https://api.github.com/repos/rickbrew/stetho/issues{/number}","pulls_url":"https://api.github.com/repos/rickbrew/stetho/pulls{/number}","milestones_url":"https://api.github.com/repos/rickbrew/stetho/milestones{/number}","notifications_url":"https://api.github.com/repos/rickbrew/stetho/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rickbrew/stetho/labels{/name}","releases_url":"https://api.github.com/repos/rickbrew/stetho/releases{/id}","created_at":"2015-02-18T21:52:05Z","updated_at":"2015-02-18T21:52:06Z","pushed_at":"2015-04-21T23:34:12Z","git_url":"git://github.com/rickbrew/stetho.git","ssh_url":"git@github.com:rickbrew/stetho.git","clone_url":"https://github.com/rickbrew/stetho.git","svn_url":"https://github.com/rickbrew/stetho","homepage":"http://facebook.github.io/stetho/","size":983,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"8e1f0dc2f0436c1de6a6afcea1f89c1a14cb5300","user":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":29703871,"name":"stetho","full_name":"facebook/stetho","owner":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/stetho","description":"Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.","fork":false,"url":"https://api.github.com/repos/facebook/stetho","forks_url":"https://api.github.com/repos/facebook/stetho/forks","keys_url":"https://api.github.com/repos/facebook/stetho/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/stetho/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/stetho/teams","hooks_url":"https://api.github.com/repos/facebook/stetho/hooks","issue_events_url":"https://api.github.com/repos/facebook/stetho/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/stetho/events","assignees_url":"https://api.github.com/repos/facebook/stetho/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/stetho/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/stetho/tags","blobs_url":"https://api.github.com/repos/facebook/stetho/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/stetho/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/stetho/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/stetho/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/stetho/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/stetho/languages","stargazers_url":"https://api.github.com/repos/facebook/stetho/stargazers","contributors_url":"https://api.github.com/repos/facebook/stetho/contributors","subscribers_url":"https://api.github.com/repos/facebook/stetho/subscribers","subscription_url":"https://api.github.com/repos/facebook/stetho/subscription","commits_url":"https://api.github.com/repos/facebook/stetho/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/stetho/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/stetho/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/stetho/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/stetho/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/stetho/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/stetho/merges","archive_url":"https://api.github.com/repos/facebook/stetho/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/stetho/downloads","issues_url":"https://api.github.com/repos/facebook/stetho/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/stetho/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/stetho/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/stetho/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/stetho/labels{/name}","releases_url":"https://api.github.com/repos/facebook/stetho/releases{/id}","created_at":"2015-01-22T22:34:10Z","updated_at":"2015-04-23T16:27:10Z","pushed_at":"2015-04-22T23:55:36Z","git_url":"git://github.com/facebook/stetho.git","ssh_url":"git@github.com:facebook/stetho.git","clone_url":"https://github.com/facebook/stetho.git","svn_url":"https://github.com/facebook/stetho","homepage":"http://facebook.github.io/stetho/","size":3457,"stargazers_count":2477,"watchers_count":2477,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":172,"mirror_url":null,"open_issues_count":25,"forks":172,"open_issues":25,"watchers":2477,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/stetho/pulls/168"},"html":{"href":"https://github.com/facebook/stetho/pull/168"},"issue":{"href":"https://api.github.com/repos/facebook/stetho/issues/168"},"comments":{"href":"https://api.github.com/repos/facebook/stetho/issues/168/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/stetho/pulls/168/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/stetho/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/stetho/pulls/168/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/stetho/statuses/51d0cef7f064c885defcd0de2072f0d44c3f2d74"}}}}