Move validation of EndQuery out of gl::Context.

BUG=angle:571

Change-Id: I8913eb1b565a4282d9d84d06933e8b854453f17d
Reviewed-on: https://chromium-review.googlesource.com/199349
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 9d70f84..8f8666e 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -782,13 +782,18 @@
     return false;
 }
 
-GLuint Context::getActiveQuery(GLenum target) const
+const Query *Context::getActiveQuery(GLenum target) const
 {
     // All query types should already exist in the activeQueries map
     ASSERT(mState.activeQueries.find(target) != mState.activeQueries.end());
 
-    const Query *queryObject = mState.activeQueries.at(target).get();
-    return queryObject ? queryObject->id() : 0;
+    return mState.activeQueries.at(target).get();
+}
+
+GLuint Context::getActiveQueryId(GLenum target) const
+{
+    const Query *query = getActiveQuery(target);
+    return (query ? query->id() : 0u);
 }
 
 void Context::setEnableVertexAttribArray(unsigned int attribNum, bool enabled)
@@ -1383,11 +1388,7 @@
 void Context::endQuery(GLenum target)
 {
     Query *queryObject = mState.activeQueries[target].get();
-
-    if (queryObject == NULL)
-    {
-        return gl::error(GL_INVALID_OPERATION);
-    }
+    ASSERT(queryObject);
 
     queryObject->end();